authentication-zero 2.13.0 → 2.14.0

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: 34663ddecbc5d0c0276a99a7f7d0f867e90c2f731e1c56a5d508738469647795
4
- data.tar.gz: bbffe8e2dff90913524ff9744efa49cb1097d78745206579bb49251472a016ed
3
+ metadata.gz: 6a0e9d758b6d4e0b0c40fbda4a80145e842d11a5cf0b4ec06491bcef39eeae7d
4
+ data.tar.gz: 5701d90d2ca54430f67984367d2e0fd26e2fbe137a4d2d1e3261173c62072724
5
5
  SHA512:
6
- metadata.gz: 38dd57dfb438408fb9ff4099508568c90bc9416fe5e624b4e38eaeba4f886e61340a2104976e62d9214d95d57f45a15a8dac6dd8789022a4cf24f6225f4e98be
7
- data.tar.gz: 9393b6ceb9203be1bf0c5643640422ec8c64d96af34b01087f20d533ed781dd8f6b553350d698658a8b5cf1a07b36c965822a03d836451bdcec44c882f87a39f
6
+ metadata.gz: 4fcdd24221c895d34988aa6be949a9dd5ba7be283df6e48acb0431bad502c6dd8212617e766d7f547c90135ea19f4956d97369621efb5409c6907afe3d7ab65c
7
+ data.tar.gz: 93308abcdfa186d607fec5b920bae4e87c1a1f92638b74d012a7d6e3e7914339efb9c8bdb9e41e7ac36531ef082535a3933d5b7a0ebcd02ae0c56f28cb926d18
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- authentication-zero (2.13.0)
4
+ authentication-zero (2.14.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -1,3 +1,3 @@
1
1
  module AuthenticationZero
2
- VERSION = "2.13.0"
2
+ VERSION = "2.14.0"
3
3
  end
@@ -11,14 +11,12 @@ class ApplicationController < ActionController::API
11
11
  end
12
12
  <%- end -%>
13
13
  <%- if options.lockable? %>
14
- def self.lock_on(actions, wait: 1.minute, attempts: 1000, &block)
15
- before_action(only: actions) do
16
- counter = Kredis.counter("lock_on:#{request.remote_ip}:#{params[:controller]}:#{params[:action]}", expires_in: wait)
17
- counter.increment
14
+ def require_lock(wait: 1.hour, attempts: 10)
15
+ counter = Kredis.counter("require_lock:#{request.remote_ip}:#{params[:controller]}:#{params[:action]}", expires_in: wait)
16
+ counter.increment
18
17
 
19
- if counter.value > attempts
20
- instance_exec(&block)
21
- end
18
+ if counter.value > attempts
19
+ render json: { error: "You've exceeded the maximum number of attempts" }, status: :too_many_requests
22
20
  end
23
21
  end
24
22
  <%- end -%>
@@ -3,9 +3,7 @@ class Identity::PasswordResetsController < ApplicationController
3
3
 
4
4
  before_action :set_user, only: :update
5
5
  <%- if options.lockable? %>
6
- lock_on :create, wait: 1.hour, attempts: 10 do
7
- render json: { error: "You've exceeded the maximum number of attempts" }, status: :too_many_requests
8
- end
6
+ before_action :require_lock, only: :create
9
7
  <%- end -%>
10
8
 
11
9
  def create
@@ -9,14 +9,12 @@ class ApplicationController < ActionController::Base
9
9
  end
10
10
  <%- end -%>
11
11
  <%- if options.lockable? %>
12
- def self.lock_on(actions, wait: 1.minute, attempts: 1000, &block)
13
- before_action(only: actions) do
14
- counter = Kredis.counter("lock_on:#{request.remote_ip}:#{params[:controller]}:#{params[:action]}", expires_in: wait)
15
- counter.increment
12
+ def require_lock(wait: 1.hour, attempts: 10)
13
+ counter = Kredis.counter("require_lock:#{request.remote_ip}:#{params[:controller]}:#{params[:action]}", expires_in: wait)
14
+ counter.increment
16
15
 
17
- if counter.value > attempts
18
- instance_exec(&block)
19
- end
16
+ if counter.value > attempts
17
+ redirect_to new_identity_password_reset_path, alert: "You've exceeded the maximum number of attempts"
20
18
  end
21
19
  end
22
20
  <%- end -%>
@@ -3,9 +3,7 @@ class Identity::PasswordResetsController < ApplicationController
3
3
 
4
4
  before_action :set_user, only: %i[ edit update ]
5
5
  <%- if options.lockable? %>
6
- lock_on :create, wait: 1.hour, attempts: 10 do
7
- redirect_to new_identity_password_reset_path, alert: "You've exceeded the maximum number of attempts"
8
- end
6
+ before_action :require_lock, only: :create
9
7
  <%- end -%>
10
8
 
11
9
  def new
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: authentication-zero
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.13.0
4
+ version: 2.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nixon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-05-02 00:00:00.000000000 Z
11
+ date: 2022-05-03 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: