authentication-zero 2.12.5 → 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 +1 -1
- data/lib/generators/authentication/templates/controllers/html/identity/email_verifications_controller.rb.tt +2 -2
- data/lib/generators/authentication/templates/erb/user_mailer/{email_confirmation.html.erb.tt → email_verification.html.erb.tt} +0 -0
- data/lib/generators/authentication/templates/erb/user_mailer/{email_confirmation.text.erb.tt → email_verification.text.erb.tt} +0 -0
- data/lib/generators/authentication/templates/mailers/user_mailer.rb.tt +2 -2
- data/lib/generators/authentication/templates/models/user.rb.tt +1 -1
- 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 +2 -2
- data/lib/generators/authentication/templates/test_unit/controllers/html/identity/email_verifications_controller_test.rb.tt +3 -3
- metadata +4 -4
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: "
|
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 -%>
|
@@ -10,7 +10,7 @@ class Identity::PasswordResetsController < ApplicationController
|
|
10
10
|
if @user = User.find_by(email: params[:email], verified: true)
|
11
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: "
|
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
|
File without changes
|
File without changes
|
@@ -6,12 +6,12 @@ class UserMailer < ApplicationMailer
|
|
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: "
|
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"
|
@@ -28,7 +28,7 @@ class User < ApplicationRecord
|
|
28
28
|
end
|
29
29
|
|
30
30
|
after_save_commit if: :email_previously_changed? do
|
31
|
-
UserMailer.with(user: self).
|
31
|
+
UserMailer.with(user: self).email_verification.deliver_later
|
32
32
|
end
|
33
33
|
<%- if options.trackable? %>
|
34
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: "
|
7
|
-
@sid_exp = @user.signed_id(purpose: "
|
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
|
|
@@ -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: "
|
7
|
-
@sid_exp = @user.signed_id(purpose: "
|
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
|
|
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,8 +70,8 @@ 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/
|
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
75
|
- lib/generators/authentication/templates/erb/user_mailer/password_reset.html.erb.tt
|
76
76
|
- lib/generators/authentication/templates/erb/user_mailer/password_reset.text.erb.tt
|
77
77
|
- lib/generators/authentication/templates/mailers/session_mailer.rb.tt
|