authentication-zero 2.14.0 → 2.15.2

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: 6a0e9d758b6d4e0b0c40fbda4a80145e842d11a5cf0b4ec06491bcef39eeae7d
4
- data.tar.gz: 5701d90d2ca54430f67984367d2e0fd26e2fbe137a4d2d1e3261173c62072724
3
+ metadata.gz: 57381cfe8cb5f43de1b8d8946ef872528166b9d5919d3fa612d811aded172697
4
+ data.tar.gz: 98b95b24b18b7f5f8113194712261ac840405fd5df47ffd1a51e7df45e9242b8
5
5
  SHA512:
6
- metadata.gz: 4fcdd24221c895d34988aa6be949a9dd5ba7be283df6e48acb0431bad502c6dd8212617e766d7f547c90135ea19f4956d97369621efb5409c6907afe3d7ab65c
7
- data.tar.gz: 93308abcdfa186d607fec5b920bae4e87c1a1f92638b74d012a7d6e3e7914339efb9c8bdb9e41e7ac36531ef082535a3933d5b7a0ebcd02ae0c56f28cb926d18
6
+ metadata.gz: a9537217a53d7700bdb232779bb4d1c7706d045646648ec6788b9cb11e32da79b18f127d9d9f998239b7fcc74aa9c76e321d564e443b7a772c7c4cde4e30dfc3
7
+ data.tar.gz: 759a0cbab559acb22c223c990a0d169420c1f0b7f1c75606737ef6703fcf4008221073f5817fdf215b1c139522e45f4bf9381fa84a5b3fbff23ff3209e3c75b9
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- authentication-zero (2.14.0)
4
+ authentication-zero (2.15.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -19,7 +19,7 @@ The purpose of authentication zero is to generate a pre-built authentication sys
19
19
  - Reset the user password and send reset instructions
20
20
  - Reset the user password only from verified emails
21
21
  - Lock sending reset password email after many attempts (--lockable)
22
- - Rate limiting for your app, 1000 reqs/hour (--ratelimit)
22
+ - Rate limiting for your app, 1000 reqs/minute (--ratelimit)
23
23
  - Send e-mail confirmation when your email has been changed
24
24
  - Send e-mail notification when someone has logged into your account
25
25
  - Manage multiple sessions & devices
@@ -1,3 +1,3 @@
1
1
  module AuthenticationZero
2
- VERSION = "2.14.0"
2
+ VERSION = "2.15.2"
3
3
  end
@@ -5,13 +5,7 @@ class Identity::EmailsController < ApplicationController
5
5
  before_action :set_user
6
6
 
7
7
  def update
8
- <%- unless options.sudoable? -%>
9
- if !@user.authenticate(params[:current_password])
10
- render json: { error: "The password you entered is incorrect" }, status: :bad_request
11
- elsif @user.update(user_params)
12
- <%- else -%>
13
8
  if @user.update(user_params)
14
- <%- end -%>
15
9
  render json: @user
16
10
  else
17
11
  render json: @user.errors, status: :unprocessable_entity
@@ -2,7 +2,7 @@ class Identity::PasswordResetsController < ApplicationController
2
2
  skip_before_action :authenticate
3
3
 
4
4
  before_action :set_user, only: :update
5
- <%- if options.lockable? %>
5
+ <%- if options.lockable? -%>
6
6
  before_action :require_lock, only: :create
7
7
  <%- end -%>
8
8
 
@@ -14,7 +14,7 @@ class ApplicationController < ActionController::Base
14
14
  counter.increment
15
15
 
16
16
  if counter.value > attempts
17
- redirect_to new_identity_password_reset_path, alert: "You've exceeded the maximum number of attempts"
17
+ redirect_to root_path, alert: "You've exceeded the maximum number of attempts"
18
18
  end
19
19
  end
20
20
  <%- end -%>
@@ -8,13 +8,7 @@ class Identity::EmailsController < ApplicationController
8
8
  end
9
9
 
10
10
  def update
11
- <%- unless options.sudoable? -%>
12
- if !@user.authenticate(params[:current_password])
13
- redirect_to edit_identity_email_path, alert: "The password you entered is incorrect"
14
- elsif @user.update(user_params)
15
- <%- else -%>
16
11
  if @user.update(user_params)
17
- <%- end -%>
18
12
  redirect_to root_path, notice: "Your email has been changed"
19
13
  else
20
14
  render :edit, status: :unprocessable_entity
@@ -2,7 +2,7 @@ class Identity::PasswordResetsController < ApplicationController
2
2
  skip_before_action :authenticate
3
3
 
4
4
  before_action :set_user, only: %i[ edit update ]
5
- <%- if options.lockable? %>
5
+ <%- if options.lockable? -%>
6
6
  before_action :require_lock, only: :create
7
7
  <%- end -%>
8
8
 
@@ -23,7 +23,7 @@ class Identity::PasswordResetsController < ApplicationController
23
23
 
24
24
  def update
25
25
  if @user.update(user_params)
26
- @token.destroy; redirect_to sign_in_path, notice: "Your password was reset successfully. Please sign in"
26
+ @token.destroy; redirect_to(sign_in_path, notice: "Your password was reset successfully. Please sign in")
27
27
  else
28
28
  render :edit, status: :unprocessable_entity
29
29
  end
@@ -10,13 +10,7 @@ class TwoFactorAuthentication::TotpsController < ApplicationController
10
10
  end
11
11
 
12
12
  def create
13
- <%- unless options.sudoable? -%>
14
- if !@user.authenticate(params[:current_password])
15
- redirect_to two_factor_authentication_totp_path, alert: "The password you entered is incorrect"
16
- elsif @totp.verify(params[:code], drift_behind: 15)
17
- <%- else -%>
18
13
  if @totp.verify(params[:code], drift_behind: 15)
19
- <%- end -%>
20
14
  @user.update! otp_secret: params[:secret]
21
15
  redirect_to root_path, notice: "2FA is enabled on your account"
22
16
  else
@@ -21,13 +21,6 @@
21
21
  </div>
22
22
  <%% end %>
23
23
 
24
- <%- unless options.sudoable? -%>
25
- <div>
26
- <%%= form.label :current_password, style: "display: block" %>
27
- <%%= form.password_field :current_password, required: true, autofocus: true, autocomplete: "current-password" %>
28
- </div>
29
- <%- end -%>
30
-
31
24
  <div>
32
25
  <%%= form.label :email, "New email", style: "display: block" %>
33
26
  <%%= form.email_field :email %>
@@ -17,13 +17,6 @@
17
17
  <%%= form_with(url: two_factor_authentication_totp_path) do |form| %>
18
18
  <%%= form.hidden_field :secret, value: @totp.secret %>
19
19
 
20
- <%- unless options.sudoable? -%>
21
- <div>
22
- <%%= form.label :current_password, style: "display: block" %>
23
- <%%= form.password_field :current_password, required: true, autofocus: true, autocomplete: "current-password" %>
24
- </div>
25
- <%- end -%>
26
-
27
20
  <div>
28
21
  <%%= form.label :code, "After scanning with your camera, the app will generate a six-digit code. Enter it here:", style: "display: block" %>
29
22
  <%%= form.text_field :code, autofocus: true, required: true, autocomplete: :off %>
@@ -26,15 +26,19 @@ class User < ApplicationRecord
26
26
  self.verified = false
27
27
  end
28
28
 
29
+ after_create_commit do
30
+ UserMailer.with(user: self).email_verification.deliver_later
31
+ end
32
+
29
33
  after_update if: :password_digest_previously_changed? do
30
34
  sessions.where.not(id: Current.session).destroy_all
31
35
  end
32
36
 
33
- after_save_commit if: :email_previously_changed? do
37
+ after_update if: :email_previously_changed? do
34
38
  UserMailer.with(user: self).email_verification.deliver_later
35
39
  end
36
40
  <%- if options.trackable? %>
37
- after_save_commit if: :email_previously_changed? do
41
+ after_update if: :email_previously_changed? do
38
42
  events.create! action: "email_verification_requested"
39
43
  end
40
44
 
@@ -10,14 +10,7 @@ class Identity::EmailsControllerTest < ActionDispatch::IntegrationTest
10
10
  end
11
11
 
12
12
  test "should update email" do
13
- patch identity_email_url, params: { email: "new_email@hey.com", current_password: "Secret1*3*5*" }, headers: default_headers
13
+ patch identity_email_url, params: { email: "new_email@hey.com" }, headers: default_headers
14
14
  assert_response :success
15
15
  end
16
-
17
- test "should not update email with wrong current password" do
18
- patch identity_email_url, params: { email: "new_email@hey.com", current_password: "SecretWrong1*3" }, headers: default_headers
19
-
20
- assert_response :bad_request
21
- assert_equal "The password you entered is incorrect", response.parsed_body["error"]
22
- end
23
16
  end
@@ -11,14 +11,7 @@ class Identity::EmailsControllerTest < ActionDispatch::IntegrationTest
11
11
  end
12
12
 
13
13
  test "should update email" do
14
- patch identity_email_url, params: { email: "new_email@hey.com", current_password: "Secret1*3*5*" }
14
+ patch identity_email_url, params: { email: "new_email@hey.com" }
15
15
  assert_redirected_to root_url
16
16
  end
17
-
18
- test "should not update email with wrong current password" do
19
- patch identity_email_url, params: { email: "new_email@hey.com", current_password: "SecretWrong1*3" }
20
-
21
- assert_redirected_to edit_identity_email_url
22
- assert_equal "The password you entered is incorrect", flash[:alert]
23
- end
24
17
  end
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.14.0
4
+ version: 2.15.2
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-03 00:00:00.000000000 Z
11
+ date: 2022-06-03 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: