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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7af6ee1882b0f3685dc223c44daa2ad5b3114169ad7a5800541fe67d992de2b8
4
- data.tar.gz: 351736b02619a342ac1edcd8886a75e20952bbf64dc4d5cb318a255f81f18767
3
+ metadata.gz: e6fe44123abbf11de2f3e70dae2f4ff6ba2a5125bb29baf76a9ea97f8a646dad
4
+ data.tar.gz: f71ca03e448328e79038523439400dd4f1936d48269e689d72a6f2b6a7b4fbcd
5
5
  SHA512:
6
- metadata.gz: a471cb4d926d53a1aca7a818eeea9125d629fa670596d061af74530f253b250076ed2fc729bb6a137eb5bba1c783eaf439ec747d8bb6ddbc109d82d7a867c78b
7
- data.tar.gz: 4b3c72d956d7998319ff33394ba4c07db1cb379d4bc0021bab347f7527fc5524386728e98c08537000ae6040404610ab63ead61015d4dbd52ef5e2210fcd3aa4
6
+ metadata.gz: 47213666e134a5d401b6d0d8dc11648590486ee15b30877167432551b5e76f2c1dd29043126bed783b31aabd4272c0b88e951910e727ce3c264f7060098ce9d4
7
+ data.tar.gz: '0650823e3cae295e36820e6f47c4eb403d7424ccbcda400f7780c5cc7095306f1d5bea337efb103ea5f5ee976f2d209f581326179e1c752f6bd1155fc65953b8'
@@ -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
- rec ? rec.validate_captcha : true
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.attempts == 1
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.13
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-13 00:00:00.000000000 Z
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.