login-control 0.0.10 → 0.0.12

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: 8e5fe55ef77a1e22cb8412309533eb689fad1eb6974a4bc655c90ecbdd9537f8
4
- data.tar.gz: 2ac316f6a3332f45e795b2e5fb70cb842a7a30b98685daa7c009e01dbf09f07c
3
+ metadata.gz: 2ea0f78366e9c6df5f607dcf3801d2e84fb4fe96d8f1a82f3ef255475882a230
4
+ data.tar.gz: de45c02638f0e0dc61ea957c0b10e8bf629a49e3052ae230c8cefe2781a0a01e
5
5
  SHA512:
6
- metadata.gz: b1dc3fed49863c7173a6333c8a44e8775214596af7d5f2807c97514561c168ef1dc053c52549df4dc0afc247954ae86ced7af133131ce1eeb9921e7ca29e782f
7
- data.tar.gz: c504a82898c66b3658c89469797633f50b050a52699a6afa80bf7ff4cfc8038fc0f1ca7a7ef8ab385b59fe8b1fd89f931e4c83f154130d20c0a7b411a51179b2
6
+ metadata.gz: 18264367c3b418af8ae901fbe7afe173b31da25af42fd5ec2ba43493e56f4321ed890fe60fe5fa9277c7b3c9a820fe22f731ed940a172e03dbee3eaadad4266a
7
+ data.tar.gz: d6191a82cd30050ab721a541a116b9a6649686b3dd9ac62bf2073a91d37af3b724da9b10a190f804ba61fa526b81665587e21bf6cd8ed77a719957c02e05f76d
@@ -3,7 +3,7 @@ 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 "LOGIN-CONTROL => get captcha #{rec&.validate_captcha ? '' : 'NOT '}requested from record LoginControl.#{rec&.id}" if debug_request_control
6
+ logger.info "LoginControlModule => get captcha #{rec&.validate_captcha ? '' : 'NOT '}requested from record LoginControl.#{rec&.id}" if debug_request_control
7
7
  rec ? rec.validate_captcha : true
8
8
  end
9
9
 
@@ -15,7 +15,7 @@ module LoginControlModule
15
15
  rec.last_attempt = DateTime.now
16
16
  rec.attempts = 1
17
17
  rec.save!
18
- logger.info "LOGIN-CONTROL => #{rec.sign_in_success}. successful request noticed" if debug_request_control
18
+ logger.info "LoginControlModule.notice_successful_request => #{rec.sign_in_success}. successful request noticed" if debug_request_control
19
19
  end
20
20
 
21
21
  # stores cookie, counts up attempts
@@ -25,7 +25,7 @@ module LoginControlModule
25
25
  rec.attempts = rec.attempts.to_i + 1
26
26
  rec.last_attempt = DateTime.now
27
27
  rec.save!
28
- logger.info "LOGIN-CONTROL => #{rec.attempts}. failed request noticed" if debug_request_control
28
+ logger.info "LoginControlModule.notice_request_attempt => #{rec.attempts}. request attempt noticed" if debug_request_control
29
29
  end
30
30
 
31
31
  private
@@ -38,6 +38,7 @@ module LoginControlModule
38
38
  rc_record(scope, login_name, id: id)
39
39
  else
40
40
  id = SecureRandom.hex(20)
41
+ logger.info "LoginControlModule.find_or_build_rc_record => created cookie by id: «#{id}»" if debug_request_control
41
42
  cookies.encrypted.permanent[:login_control] = id
42
43
  LoginControl.new(session_id: id, scope: scope, login_name: login_name)
43
44
  end
@@ -46,7 +47,9 @@ module LoginControlModule
46
47
  # read cookie «login_control»
47
48
  def rc_record(scope, login_name, id: cookies.encrypted.permanent[:login_control])
48
49
  if id
49
- LoginControl.find_by(session_id: id, scope: scope, login_name: login_name)
50
+ lc = LoginControl.find_by(session_id: id, scope: scope, login_name: login_name)
51
+ logger.info "LoginControlModule.rc_record => #{lc ? '' : 'NOT '}found by session_id: «#{id}» #{lc ? ", record-id: #{lc.id}" : ''}" if debug_request_control
52
+ lc
50
53
  else
51
54
  nil
52
55
  end
@@ -8,38 +8,38 @@ module LoginControlViewHelper
8
8
  rc_id = cookies.encrypted.permanent[:login_control]
9
9
  captcha_requested = true
10
10
  if request.host == 'localhost'
11
- logger.info 'LOGIN-CONTROL => no captcha because of localhost' if debug
11
+ logger.info 'LoginControlViewHelper.captcha_tag? => no captcha because of localhost' if debug
12
12
  captcha_requested = false
13
13
  elsif !rc_id.present?
14
- logger.info 'LOGIN-CONTROL => captcha because no cookie stored yet' if debug
14
+ logger.info 'LoginControlViewHelper.captcha_tag? => captcha because no cookie stored yet' if debug
15
15
  captcha_requested = true
16
16
  else
17
- logger.info 'LOGIN-CONTROL => cookie found ...' if debug
17
+ logger.info 'LoginControlViewHelper.captcha_tag? => cookie found ...' if debug
18
18
  rec = LoginControl.find_by(session_id: rc_id, scope: scope, login_name: login_name)
19
19
  if !rec
20
- logger.info 'LOGIN-CONTROL => captcha required because no record found(!)' if debug
20
+ logger.info 'LoginControlViewHelper.captcha_tag? => captcha required because no record found(!)' if debug
21
21
  true
22
22
  else
23
- logger.info 'LOGIN-CONTROL => record found ...' if debug
23
+ logger.info 'LoginControlViewHelper.captcha_tag? => record found ...' if debug
24
24
 
25
25
  attempts_allowed = (Rails.configuration.x.login_control.attempts_allowed || 10)
26
26
  retry_after_seconds = (Rails.configuration.x.login_control.retry_after_seconds || 30)
27
- logger.info "LOGIN-CONTROL => #{rec.attempts.to_i}. attempt (config.x.attempts_allowed: #{attempts_allowed})" if debug
27
+ logger.info "LoginControlViewHelper.captcha_tag? => #{rec.attempts.to_i}. attempt (config.x.attempts_allowed: #{attempts_allowed})" if debug
28
28
 
29
29
  if rec.attempts == 1
30
30
  captcha_requested = false
31
- logger.info "LOGIN-CONTROL => captcha NOT requested: because first attempt after successful login" if debug
31
+ logger.info "LoginControlViewHelper.captcha_tag? => captcha NOT requested: because first attempt after successful login" if debug
32
32
  elsif rec.attempts.to_i <= attempts_allowed
33
33
  secs = Time.now - (rec.last_attempt || Time.now)
34
34
  if secs >= retry_after_seconds.to_f
35
35
  captcha_requested = false
36
- logger.info "LOGIN-CONTROL => captcha #{captcha_requested ? '' : 'NOT '}requested: config.x.retry_after_seconds(#{retry_after_seconds}) >= secs(#{secs})" if debug
36
+ logger.info "LoginControlViewHelper.captcha_tag? => captcha #{captcha_requested ? '' : 'NOT '}requested: config.x.retry_after_seconds(#{retry_after_seconds}) >= secs(#{secs})" if debug
37
37
  end
38
38
  end
39
39
 
40
40
  end
41
41
  rec.update!(validate_captcha: captcha_requested)
42
- logger.info "LOGIN-CONTROL => set captcha #{captcha_requested ? '' : 'NOT '}requested to record LoginControl.#{rec.id}" if debug
42
+ logger.info "LoginControlViewHelper.captcha_tag? => set captcha #{captcha_requested ? '' : 'NOT '}requested to record LoginControl.#{rec.id}" if debug
43
43
  captcha_requested
44
44
  end
45
45
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: login-control
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christian Sedlmair