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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e6fe44123abbf11de2f3e70dae2f4ff6ba2a5125bb29baf76a9ea97f8a646dad
4
- data.tar.gz: f71ca03e448328e79038523439400dd4f1936d48269e689d72a6f2b6a7b4fbcd
3
+ metadata.gz: 4c994c7999c34ab1e07335a16f36d527834a8591f6848f6009aa894ed5a12076
4
+ data.tar.gz: 2822fe19d6389196d1fb487924087d981635b828a176601543f44a606e99292c
5
5
  SHA512:
6
- metadata.gz: 47213666e134a5d401b6d0d8dc11648590486ee15b30877167432551b5e76f2c1dd29043126bed783b31aabd4272c0b88e951910e727ce3c264f7060098ce9d4
7
- data.tar.gz: '0650823e3cae295e36820e6f47c4eb403d7424ccbcda400f7780c5cc7095306f1d5bea337efb103ea5f5ee976f2d209f581326179e1c752f6bd1155fc65953b8'
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 'request-control'`
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
- notice_request_attempt
53
+ notice_login_attempt
54
54
  if (captcha_validation? ? verify_hcaptcha(secret_key: ...) : true) && credentials-matched
55
55
  super
56
- notice_successful_request
56
+ notice_successful_login
57
57
  else
58
58
  redirect_to login_path, alert: 'captcha failed'
59
59
  end
@@ -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 notice_successful_request(scope: :global, login_name: nil)
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.notice_successful_request => #{rec.sign_in_success}. successful request noticed" if debug_request_control
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 notice_request_attempt(scope: :global, login_name: nil)
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.notice_request_attempt => #{rec.attempts}. request attempt noticed" if debug_request_control
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.15
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-17 00:00:00.000000000 Z
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.