authentication-zero 2.12.3 → 2.12.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/authentication_zero/version.rb +1 -1
- data/lib/generators/authentication/templates/controllers/api/identity/email_verifications_controller.rb.tt +2 -2
- data/lib/generators/authentication/templates/controllers/api/identity/password_resets_controller.rb.tt +2 -2
- data/lib/generators/authentication/templates/controllers/html/identity/email_verifications_controller.rb.tt +2 -2
- data/lib/generators/authentication/templates/controllers/html/identity/password_resets_controller.rb.tt +1 -1
- data/lib/generators/authentication/templates/erb/user_mailer/{email_verify_confirmation.html.erb.tt → email_verification.html.erb.tt} +0 -0
- data/lib/generators/authentication/templates/erb/user_mailer/{email_verify_confirmation.text.erb.tt → email_verification.text.erb.tt} +0 -0
- data/lib/generators/authentication/templates/erb/user_mailer/{password_reset_provision.html.erb.tt → password_reset.html.erb.tt} +0 -0
- data/lib/generators/authentication/templates/erb/user_mailer/{password_reset_provision.text.erb.tt → password_reset.text.erb.tt} +0 -0
- data/lib/generators/authentication/templates/mailers/user_mailer.rb.tt +3 -3
- data/lib/generators/authentication/templates/models/user.rb.tt +4 -7
- data/lib/generators/authentication/templates/test_unit/controllers/api/identity/email_verifications_controller_test.rb.tt +3 -3
- data/lib/generators/authentication/templates/test_unit/controllers/api/identity/password_resets_controller_test.rb.tt +3 -3
- data/lib/generators/authentication/templates/test_unit/controllers/html/identity/email_verifications_controller_test.rb.tt +3 -3
- data/lib/generators/authentication/templates/test_unit/controllers/html/identity/password_resets_controller_test.rb.tt +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 39712c822deb0a2df94156ce44de1cbcd604be043498b56b2139c0dce6d81e51
|
4
|
+
data.tar.gz: 3e4704a6d3cc5c1e2da391deee5f9e5f2b4ce43374a555e3535f6ddbdfbfbb3d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b2ca2648b71d9429eab8811922bb44985d158702373908fbd4a58bc40e6f0bd08fc28b4e7e58f4f6ecb6cdb837ffede42ea8aadeb7c0991fc0e85558a7319644
|
7
|
+
data.tar.gz: '0897ed09e494352a9429db06982c160b5259578e2dfa0f21cd51e37d0dc57975e847af1e3147af84cf069cf3c4c28e06772581a85480c12686ca27d975a463b6'
|
data/Gemfile.lock
CHANGED
@@ -8,7 +8,7 @@ class Identity::EmailVerificationsController < ApplicationController
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def create
|
11
|
-
UserMailer.with(user: Current.user).
|
11
|
+
UserMailer.with(user: Current.user).email_verification.deliver_later
|
12
12
|
end
|
13
13
|
|
14
14
|
private
|
@@ -22,7 +22,7 @@ class Identity::EmailVerificationsController < ApplicationController
|
|
22
22
|
render json: { error: "That email verification code is invalid" }, status: :bad_request
|
23
23
|
end
|
24
24
|
<%- else -%>
|
25
|
-
@user = User.where(email: params[:email]).find_signed!(params[:token], purpose: params[:email])
|
25
|
+
@user = User.where(email: params[:email]).find_signed!(params[:token], purpose: "email_verification/#{params[:email]}")
|
26
26
|
rescue
|
27
27
|
render json: { error: "That email verification link is invalid" }, status: :bad_request
|
28
28
|
<%- end -%>
|
@@ -8,9 +8,9 @@ class Identity::PasswordResetsController < ApplicationController
|
|
8
8
|
|
9
9
|
def create
|
10
10
|
if @user = User.find_by(email: params[:email], verified: true)
|
11
|
-
UserMailer.with(user: @user).
|
11
|
+
UserMailer.with(user: @user).password_reset.deliver_later
|
12
12
|
else
|
13
|
-
render json: { error: "You can't reset your password until you verify your email" }, status: :
|
13
|
+
render json: { error: "You can't reset your password until you verify your email" }, status: :bad_request
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
@@ -9,13 +9,13 @@ class Identity::EmailVerificationsController < ApplicationController
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def create
|
12
|
-
UserMailer.with(user: Current.user).
|
12
|
+
UserMailer.with(user: Current.user).email_verification.deliver_later
|
13
13
|
redirect_to root_path, notice: "We sent a verification email to your email address"
|
14
14
|
end
|
15
15
|
|
16
16
|
private
|
17
17
|
def set_user
|
18
|
-
@user = User.where(email: params[:email]).find_signed!(params[:token], purpose: params[:email])
|
18
|
+
@user = User.where(email: params[:email]).find_signed!(params[:token], purpose: "email_verification/#{params[:email]}")
|
19
19
|
rescue
|
20
20
|
redirect_to edit_identity_email_path, alert: "That email verification link is invalid"
|
21
21
|
end
|
@@ -14,7 +14,7 @@ class Identity::PasswordResetsController < ApplicationController
|
|
14
14
|
|
15
15
|
def create
|
16
16
|
if @user = User.find_by(email: params[:email], verified: true)
|
17
|
-
UserMailer.with(user: @user).
|
17
|
+
UserMailer.with(user: @user).password_reset.deliver_later
|
18
18
|
redirect_to sign_in_path, notice: "Check your email for reset instructions"
|
19
19
|
else
|
20
20
|
redirect_to new_identity_password_reset_path, alert: "You can't reset your password until you verify your email"
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -1,17 +1,17 @@
|
|
1
1
|
class UserMailer < ApplicationMailer
|
2
|
-
def
|
2
|
+
def password_reset
|
3
3
|
@user = params[:user]
|
4
4
|
@signed_id = @user.signed_id(purpose: :password_reset, expires_in: 20.minutes)
|
5
5
|
|
6
6
|
mail to: @user.email, subject: "Reset your password"
|
7
7
|
end
|
8
8
|
|
9
|
-
def
|
9
|
+
def email_verification
|
10
10
|
@user = params[:user]
|
11
11
|
<%- if code_verifiable? -%>
|
12
12
|
@user.verification_code.value = rand.to_s[2..7]
|
13
13
|
<%- else -%>
|
14
|
-
@signed_id = @user.signed_id(purpose: @user.email, expires_in: 2.days)
|
14
|
+
@signed_id = @user.signed_id(purpose: "email_verification/#{@user.email}", expires_in: 2.days)
|
15
15
|
<%- end -%>
|
16
16
|
|
17
17
|
mail to: @user.email, subject: "Verify your email"
|
@@ -9,17 +9,14 @@ class User < ApplicationRecord
|
|
9
9
|
kredis_string :verification_code, expires_in: 2.days
|
10
10
|
<%- end -%>
|
11
11
|
|
12
|
-
validates :email, presence: true, uniqueness: true
|
13
|
-
|
14
|
-
|
15
|
-
validates_length_of :password, minimum: 12, allow_nil: true
|
16
|
-
validates_format_of :password, with: /(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])/, allow_nil: true, message: "might easily be guessed"
|
12
|
+
validates :email, presence: true, uniqueness: true, format: { with: URI::MailTo::EMAIL_REGEXP }
|
13
|
+
validates :password, allow_nil: true, length: { minimum: 12 }, format: { with: /(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])/ }
|
17
14
|
<%- if options.pwned? -%>
|
18
15
|
validates :password, not_pwned: { message: "might easily be guessed" }
|
19
16
|
<%- end -%>
|
20
17
|
|
21
18
|
before_validation do
|
22
|
-
self.email = email.downcase.strip
|
19
|
+
self.email = email.try(:downcase).try(:strip)
|
23
20
|
end
|
24
21
|
|
25
22
|
before_validation if: :email_changed? do
|
@@ -31,7 +28,7 @@ class User < ApplicationRecord
|
|
31
28
|
end
|
32
29
|
|
33
30
|
after_save_commit if: :email_previously_changed? do
|
34
|
-
UserMailer.with(user: self).
|
31
|
+
UserMailer.with(user: self).email_verification.deliver_later
|
35
32
|
end
|
36
33
|
<%- if options.trackable? %>
|
37
34
|
after_save_commit if: :email_previously_changed? do
|
@@ -3,8 +3,8 @@ require "test_helper"
|
|
3
3
|
class Identity::EmailVerificationsControllerTest < ActionDispatch::IntegrationTest
|
4
4
|
setup do
|
5
5
|
@user, @token = sign_in_as(users(:lazaro_nixon))
|
6
|
-
@sid = @user.signed_id(purpose: @user.email, expires_in: 20.minutes)
|
7
|
-
@sid_exp = @user.signed_id(purpose: @user.email, expires_in: 0.minutes)
|
6
|
+
@sid = @user.signed_id(purpose: "email_verification/#{@user.email}", expires_in: 20.minutes)
|
7
|
+
@sid_exp = @user.signed_id(purpose: "email_verification/#{@user.email}", expires_in: 0.minutes)
|
8
8
|
|
9
9
|
@user.update! verified: false
|
10
10
|
end
|
@@ -14,7 +14,7 @@ class Identity::EmailVerificationsControllerTest < ActionDispatch::IntegrationTe
|
|
14
14
|
end
|
15
15
|
|
16
16
|
test "should send a verification email" do
|
17
|
-
assert_enqueued_email_with UserMailer, :
|
17
|
+
assert_enqueued_email_with UserMailer, :email_verification, args: { user: @user } do
|
18
18
|
post identity_email_verification_url, headers: default_headers
|
19
19
|
end
|
20
20
|
|
@@ -8,7 +8,7 @@ class Identity::PasswordResetsControllerTest < ActionDispatch::IntegrationTest
|
|
8
8
|
end
|
9
9
|
|
10
10
|
test "should send a password reset email" do
|
11
|
-
assert_enqueued_email_with UserMailer, :
|
11
|
+
assert_enqueued_email_with UserMailer, :password_reset, args: { user: @user } do
|
12
12
|
post identity_password_reset_url, params: { email: @user.email }
|
13
13
|
end
|
14
14
|
|
@@ -20,7 +20,7 @@ class Identity::PasswordResetsControllerTest < ActionDispatch::IntegrationTest
|
|
20
20
|
post identity_password_reset_url, params: { email: "invalid_email@hey.com" }
|
21
21
|
end
|
22
22
|
|
23
|
-
assert_response :
|
23
|
+
assert_response :bad_request
|
24
24
|
assert_equal "You can't reset your password until you verify your email", response.parsed_body["error"]
|
25
25
|
end
|
26
26
|
|
@@ -31,7 +31,7 @@ class Identity::PasswordResetsControllerTest < ActionDispatch::IntegrationTest
|
|
31
31
|
post identity_password_reset_url, params: { email: @user.email }
|
32
32
|
end
|
33
33
|
|
34
|
-
assert_response :
|
34
|
+
assert_response :bad_request
|
35
35
|
assert_equal "You can't reset your password until you verify your email", response.parsed_body["error"]
|
36
36
|
end
|
37
37
|
|
@@ -3,14 +3,14 @@ require "test_helper"
|
|
3
3
|
class Identity::EmailVerificationsControllerTest < ActionDispatch::IntegrationTest
|
4
4
|
setup do
|
5
5
|
@user = sign_in_as(users(:lazaro_nixon))
|
6
|
-
@sid = @user.signed_id(purpose: @user.email, expires_in: 20.minutes)
|
7
|
-
@sid_exp = @user.signed_id(purpose: @user.email, expires_in: 0.minutes)
|
6
|
+
@sid = @user.signed_id(purpose: "email_verification/#{@user.email}", expires_in: 20.minutes)
|
7
|
+
@sid_exp = @user.signed_id(purpose: "email_verification/#{@user.email}", expires_in: 0.minutes)
|
8
8
|
|
9
9
|
@user.update! verified: false
|
10
10
|
end
|
11
11
|
|
12
12
|
test "should send a verification email" do
|
13
|
-
assert_enqueued_email_with UserMailer, :
|
13
|
+
assert_enqueued_email_with UserMailer, :email_verification, args: { user: @user } do
|
14
14
|
post identity_email_verification_url
|
15
15
|
end
|
16
16
|
|
@@ -18,7 +18,7 @@ class Identity::PasswordResetsControllerTest < ActionDispatch::IntegrationTest
|
|
18
18
|
end
|
19
19
|
|
20
20
|
test "should send a password reset email" do
|
21
|
-
assert_enqueued_email_with UserMailer, :
|
21
|
+
assert_enqueued_email_with UserMailer, :password_reset, args: { user: @user } do
|
22
22
|
post identity_password_reset_url, params: { email: @user.email }
|
23
23
|
end
|
24
24
|
|
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.12.
|
4
|
+
version: 2.12.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nixon
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-04-
|
11
|
+
date: 2022-04-29 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|
@@ -70,10 +70,10 @@ files:
|
|
70
70
|
- lib/generators/authentication/templates/erb/sessions/sudos/new.html.erb.tt
|
71
71
|
- lib/generators/authentication/templates/erb/two_factor_authentication/challenges/new.html.erb.tt
|
72
72
|
- lib/generators/authentication/templates/erb/two_factor_authentication/totps/new.html.erb.tt
|
73
|
-
- lib/generators/authentication/templates/erb/user_mailer/
|
74
|
-
- lib/generators/authentication/templates/erb/user_mailer/
|
75
|
-
- lib/generators/authentication/templates/erb/user_mailer/
|
76
|
-
- lib/generators/authentication/templates/erb/user_mailer/
|
73
|
+
- lib/generators/authentication/templates/erb/user_mailer/email_verification.html.erb.tt
|
74
|
+
- lib/generators/authentication/templates/erb/user_mailer/email_verification.text.erb.tt
|
75
|
+
- lib/generators/authentication/templates/erb/user_mailer/password_reset.html.erb.tt
|
76
|
+
- lib/generators/authentication/templates/erb/user_mailer/password_reset.text.erb.tt
|
77
77
|
- lib/generators/authentication/templates/mailers/session_mailer.rb.tt
|
78
78
|
- lib/generators/authentication/templates/mailers/user_mailer.rb.tt
|
79
79
|
- lib/generators/authentication/templates/migrations/create_events_migration.rb.tt
|