login-control 0.0.15 → 0.0.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +3 -3
- data/lib/login_control_module.rb +10 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4c994c7999c34ab1e07335a16f36d527834a8591f6848f6009aa894ed5a12076
|
4
|
+
data.tar.gz: 2822fe19d6389196d1fb487924087d981635b828a176601543f44a606e99292c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c8ffc4147cdf9c9ba480fc1e243b37076ef4cc849076ecfe16077104123801452010003817c1d59002b11eadf3be64d42069f680a4d978655735df75f884b02a
|
7
|
+
data.tar.gz: 70e576d62335077e76f27f9661dfbc7f3d32dd139220e5390abc7d699c8b56c8877c29c5926d374d89e5083508342e4654b50da10c3dacddd3ec779008233427
|
data/README.md
CHANGED
@@ -16,7 +16,7 @@ On localhost captcha is never required.
|
|
16
16
|
|
17
17
|
## Installation
|
18
18
|
|
19
|
-
`gem '
|
19
|
+
`gem 'login-control'`
|
20
20
|
|
21
21
|
run
|
22
22
|
```
|
@@ -50,10 +50,10 @@ class SessionsController < Devise::SessionsController
|
|
50
50
|
include LoginControlModule
|
51
51
|
|
52
52
|
def create
|
53
|
-
|
53
|
+
notice_login_attempt
|
54
54
|
if (captcha_validation? ? verify_hcaptcha(secret_key: ...) : true) && credentials-matched
|
55
55
|
super
|
56
|
-
|
56
|
+
notice_successful_login
|
57
57
|
else
|
58
58
|
redirect_to login_path, alert: 'captcha failed'
|
59
59
|
end
|
data/lib/login_control_module.rb
CHANGED
@@ -3,35 +3,40 @@ module LoginControlModule
|
|
3
3
|
# check if captcha is to validate (does not store a cookie)
|
4
4
|
def captcha_validation?(scope: :global, login_name: nil)
|
5
5
|
rec = rc_record(scope, login_name)
|
6
|
-
logger.info "LoginControlModule => get captcha #{rec&.validate_captcha ? '' : 'NOT '}requested from record LoginControl.#{rec&.id}" if debug_request_control
|
7
6
|
if request.host == 'localhost'
|
7
|
+
logger.info "LoginControlModule.captcha_validation? => captcha NOT requested because localhost" if debug_request_control
|
8
|
+
false
|
9
|
+
elsif Rails.env.development? || Rails.env == 'test'
|
10
|
+
logger.info "LoginControlModule.captcha_validation? => captcha NOT requested because Rails.env #{Rails.env}" if debug_request_control
|
8
11
|
false
|
9
12
|
elsif rec
|
13
|
+
logger.info "LoginControlModule.captcha_validation? => get captcha #{rec&.validate_captcha ? '' : 'NOT '}requested from record LoginControl.#{rec&.id}" if debug_request_control
|
10
14
|
rec.validate_captcha
|
11
15
|
else
|
16
|
+
logger.info "LoginControlModule.captcha_validation? => get captcha requested (all other conditions failed)" if debug_request_control
|
12
17
|
true
|
13
18
|
end
|
14
19
|
end
|
15
20
|
|
16
21
|
# stores cookie, count-up sign_in_success, set attempts count to 1
|
17
22
|
|
18
|
-
def
|
23
|
+
def notice_successful_login(scope: :global, login_name: nil)
|
19
24
|
rec = find_or_build_rc_record(scope, login_name)
|
20
25
|
rec.sign_in_success = rec.sign_in_success.to_i + 1
|
21
26
|
rec.last_attempt = DateTime.now
|
22
27
|
rec.attempts = 1
|
23
28
|
rec.save!
|
24
|
-
logger.info "LoginControlModule.
|
29
|
+
logger.info "LoginControlModule.notice_successful_login => #{rec.sign_in_success}. successful request noticed" if debug_request_control
|
25
30
|
end
|
26
31
|
|
27
32
|
# stores cookie, counts up attempts
|
28
33
|
|
29
|
-
def
|
34
|
+
def notice_login_attempt(scope: :global, login_name: nil)
|
30
35
|
rec = find_or_build_rc_record(scope, login_name)
|
31
36
|
rec.attempts = rec.attempts.to_i + 1
|
32
37
|
rec.last_attempt = DateTime.now
|
33
38
|
rec.save!
|
34
|
-
logger.info "LoginControlModule.
|
39
|
+
logger.info "LoginControlModule.notice_login_attempt => #{rec.attempts}. request attempt noticed" if debug_request_control
|
35
40
|
end
|
36
41
|
|
37
42
|
private
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: login-control
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.17
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christian Sedlmair
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-01-
|
11
|
+
date: 2023-01-28 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Based on Login Attempts check if captcha is necessary. It stores a permanent
|
14
14
|
cookie and uses a table for tracking login requests.
|