login-control 0.0.13 → 0.0.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/login_control_module.rb +7 -1
- data/lib/login_control_view_helper.rb +5 -2
- 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: e6fe44123abbf11de2f3e70dae2f4ff6ba2a5125bb29baf76a9ea97f8a646dad
|
4
|
+
data.tar.gz: f71ca03e448328e79038523439400dd4f1936d48269e689d72a6f2b6a7b4fbcd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 47213666e134a5d401b6d0d8dc11648590486ee15b30877167432551b5e76f2c1dd29043126bed783b31aabd4272c0b88e951910e727ce3c264f7060098ce9d4
|
7
|
+
data.tar.gz: '0650823e3cae295e36820e6f47c4eb403d7424ccbcda400f7780c5cc7095306f1d5bea337efb103ea5f5ee976f2d209f581326179e1c752f6bd1155fc65953b8'
|
data/lib/login_control_module.rb
CHANGED
@@ -4,7 +4,13 @@ module LoginControlModule
|
|
4
4
|
def captcha_validation?(scope: :global, login_name: nil)
|
5
5
|
rec = rc_record(scope, login_name)
|
6
6
|
logger.info "LoginControlModule => get captcha #{rec&.validate_captcha ? '' : 'NOT '}requested from record LoginControl.#{rec&.id}" if debug_request_control
|
7
|
-
|
7
|
+
if request.host == 'localhost'
|
8
|
+
false
|
9
|
+
elsif rec
|
10
|
+
rec.validate_captcha
|
11
|
+
else
|
12
|
+
true
|
13
|
+
end
|
8
14
|
end
|
9
15
|
|
10
16
|
# stores cookie, count-up sign_in_success, set attempts count to 1
|
@@ -26,7 +26,10 @@ module LoginControlViewHelper
|
|
26
26
|
retry_after_seconds = (Rails.configuration.x.login_control.retry_after_seconds || 30)
|
27
27
|
logger.info "LoginControlViewHelper.captcha_tag? => #{rec.attempts.to_i}. attempt (config.x.attempts_allowed: #{attempts_allowed})" if debug
|
28
28
|
|
29
|
-
if rec.
|
29
|
+
if rec.sign_in_success.to_i == 0
|
30
|
+
captcha_requested = true
|
31
|
+
logger.info "LoginControlViewHelper.captcha_tag? => captcha requested: because no successful login yet" if debug
|
32
|
+
elsif rec.attempts == 1
|
30
33
|
captcha_requested = false
|
31
34
|
logger.info "LoginControlViewHelper.captcha_tag? => captcha NOT requested: because first attempt after successful login" if debug
|
32
35
|
elsif rec.attempts.to_i <= attempts_allowed
|
@@ -40,8 +43,8 @@ module LoginControlViewHelper
|
|
40
43
|
end
|
41
44
|
rec.update!(validate_captcha: captcha_requested)
|
42
45
|
logger.info "LoginControlViewHelper.captcha_tag? => set captcha #{captcha_requested ? '' : 'NOT '}requested to record LoginControl.#{rec.id}" if debug
|
43
|
-
captcha_requested
|
44
46
|
end
|
47
|
+
captcha_requested
|
45
48
|
end
|
46
49
|
|
47
50
|
# Text for ask a user for storing a cookie
|
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.15
|
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-17 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.
|