authentication-zero 2.12.2 → 2.12.5
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/api/registrations_controller.rb.tt +0 -3
- 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_confirmation.html.erb.tt} +0 -0
- data/lib/generators/authentication/templates/erb/user_mailer/{email_verify_confirmation.text.erb.tt → email_confirmation.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 +1 -1
- 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: 56295ed54d4a467ec1245634e3ab828d5128c601805bdaff0f232f9cd69ed08e
|
4
|
+
data.tar.gz: c8789b35631e6f4be5c6ba3f666eaa997f5dcdca2c23ba23fe013b0f55d36e2c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 31e6c3963edabe40e298b758d4295ab03f13960aa5dae81089f4f2c3769589c45b56b2a4cd2c7faad373b681b03c5f52a90bb4a55696d64c203c6ae60b860ca0
|
7
|
+
data.tar.gz: 6cebd96d1801c3d53de594d16d8b9864683acd1b4a176cf6c7bcf6f706e57a8a8865c845ae9faa793070ebff733436bd48bca65f52d21e4dcce660861960fe63
|
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_confirmation.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: "verify_#{params[:email]}")
|
26
26
|
rescue
|
27
27
|
render json: { error: "That email verification link is invalid" }, status: :bad_request
|
28
28
|
<%- end -%>
|
@@ -8,7 +8,7 @@ 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
13
|
render json: { error: "You can't reset your password until you verify your email" }, status: :not_found
|
14
14
|
end
|
@@ -5,9 +5,6 @@ class RegistrationsController < ApplicationController
|
|
5
5
|
@user = User.new(user_params)
|
6
6
|
|
7
7
|
if @user.save
|
8
|
-
session = @user.sessions.create!
|
9
|
-
response.set_header "X-Session-Token", session.signed_id
|
10
|
-
|
11
8
|
render json: @user, status: :created
|
12
9
|
else
|
13
10
|
render json: @user.errors, status: :unprocessable_entity
|
@@ -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_confirmation.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: "verify_#{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_confirmation
|
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: "verify_#{@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_confirmation.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: "verify_#{@user.email}", expires_in: 20.minutes)
|
7
|
+
@sid_exp = @user.signed_id(purpose: "verify_#{@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_confirmation, 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
|
|
@@ -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: "verify_#{@user.email}", expires_in: 20.minutes)
|
7
|
+
@sid_exp = @user.signed_id(purpose: "verify_#{@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_confirmation, 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.5
|
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-23 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_confirmation.html.erb.tt
|
74
|
+
- lib/generators/authentication/templates/erb/user_mailer/email_confirmation.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
|