authentication-zero 2.11.2 → 2.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +1 -1
- data/README.md +1 -1
- data/lib/authentication_zero/version.rb +1 -1
- data/lib/generators/authentication/USAGE +1 -1
- data/lib/generators/authentication/authentication_generator.rb +6 -6
- data/lib/generators/authentication/templates/controllers/api/authentications/events_controller.rb.tt +1 -1
- data/lib/generators/authentication/templates/controllers/api/identity/email_verifications_controller.rb.tt +9 -7
- data/lib/generators/authentication/templates/controllers/api/identity/emails_controller.rb.tt +15 -8
- data/lib/generators/authentication/templates/controllers/api/identity/password_resets_controller.rb.tt +9 -9
- data/lib/generators/authentication/templates/controllers/api/passwords_controller.rb.tt +8 -8
- data/lib/generators/authentication/templates/controllers/api/registrations_controller.rb.tt +5 -5
- data/lib/generators/authentication/templates/controllers/api/sessions/sudos_controller.rb.tt +1 -1
- data/lib/generators/authentication/templates/controllers/api/sessions_controller.rb.tt +5 -5
- data/lib/generators/authentication/templates/controllers/html/authentications/events_controller.rb.tt +1 -1
- data/lib/generators/authentication/templates/controllers/html/identity/email_verifications_controller.rb.tt +5 -5
- data/lib/generators/authentication/templates/controllers/html/identity/emails_controller.rb.tt +13 -6
- data/lib/generators/authentication/templates/controllers/html/identity/password_resets_controller.rb.tt +7 -7
- data/lib/generators/authentication/templates/controllers/html/passwords_controller.rb.tt +6 -6
- data/lib/generators/authentication/templates/controllers/html/registrations_controller.rb.tt +5 -5
- data/lib/generators/authentication/templates/controllers/html/sessions/omniauth_controller.rb.tt +4 -4
- data/lib/generators/authentication/templates/controllers/html/sessions/sudos_controller.rb.tt +2 -2
- data/lib/generators/authentication/templates/controllers/html/sessions_controller.rb.tt +9 -9
- data/lib/generators/authentication/templates/controllers/html/two_factor_authentication/challenges_controller.rb.tt +5 -5
- data/lib/generators/authentication/templates/controllers/html/two_factor_authentication/totps_controller.rb.tt +13 -6
- data/lib/generators/authentication/templates/erb/authentications/events/{index.html.erb → index.html.erb.tt} +8 -8
- data/lib/generators/authentication/templates/erb/identity/emails/edit.html.erb.tt +6 -4
- data/lib/generators/authentication/templates/erb/identity/password_resets/edit.html.erb.tt +3 -3
- data/lib/generators/authentication/templates/erb/passwords/edit.html.erb.tt +3 -3
- data/lib/generators/authentication/templates/erb/registrations/new.html.erb.tt +3 -3
- data/lib/generators/authentication/templates/erb/session_mailer/signed_in_notification.html.erb.tt +1 -1
- data/lib/generators/authentication/templates/erb/session_mailer/signed_in_notification.text.erb.tt +1 -1
- data/lib/generators/authentication/templates/erb/sessions/new.html.erb.tt +3 -2
- data/lib/generators/authentication/templates/erb/two_factor_authentication/totps/new.html.erb.tt +2 -0
- data/lib/generators/authentication/templates/erb/{identity_mailer → user_mailer}/email_verify_confirmation.html.erb.tt +2 -2
- data/lib/generators/authentication/templates/erb/{identity_mailer → user_mailer}/email_verify_confirmation.text.erb.tt +2 -2
- data/lib/generators/authentication/templates/erb/{identity_mailer → user_mailer}/password_reset_provision.html.erb.tt +1 -1
- data/lib/generators/authentication/templates/erb/{identity_mailer → user_mailer}/password_reset_provision.text.erb.tt +1 -1
- data/lib/generators/authentication/templates/mailers/session_mailer.rb.tt +1 -1
- data/lib/generators/authentication/templates/mailers/user_mailer.rb.tt +19 -0
- data/lib/generators/authentication/templates/migrations/create_events_migration.rb.tt +1 -1
- data/lib/generators/authentication/templates/migrations/create_sessions_migration.rb.tt +1 -1
- data/lib/generators/authentication/templates/migrations/{create_table_migration.rb.tt → create_users_migration.rb.tt} +3 -3
- data/lib/generators/authentication/templates/models/current.rb.tt +2 -2
- data/lib/generators/authentication/templates/models/event.rb.tt +1 -1
- data/lib/generators/authentication/templates/models/session.rb.tt +3 -3
- data/lib/generators/authentication/templates/models/{model.rb.tt → user.rb.tt} +2 -2
- data/lib/generators/authentication/templates/test_unit/application_system_test_case.rb.tt +3 -3
- data/lib/generators/authentication/templates/test_unit/controllers/api/identity/email_verifications_controller_test.rb.tt +9 -9
- data/lib/generators/authentication/templates/test_unit/controllers/api/identity/emails_controller_test.rb.tt +1 -1
- data/lib/generators/authentication/templates/test_unit/controllers/api/identity/password_resets_controller_test.rb.tt +7 -7
- data/lib/generators/authentication/templates/test_unit/controllers/api/passwords_controller_test.rb.tt +1 -1
- data/lib/generators/authentication/templates/test_unit/controllers/api/registrations_controller_test.rb.tt +1 -1
- data/lib/generators/authentication/templates/test_unit/controllers/api/sessions_controller_test.rb.tt +6 -6
- data/lib/generators/authentication/templates/test_unit/controllers/html/identity/email_verifications_controller_test.rb.tt +9 -9
- data/lib/generators/authentication/templates/test_unit/controllers/html/identity/emails_controller_test.rb.tt +1 -1
- data/lib/generators/authentication/templates/test_unit/controllers/html/identity/password_resets_controller_test.rb.tt +7 -7
- data/lib/generators/authentication/templates/test_unit/controllers/html/passwords_controller_test.rb.tt +1 -1
- data/lib/generators/authentication/templates/test_unit/controllers/html/registrations_controller_test.rb.tt +1 -1
- data/lib/generators/authentication/templates/test_unit/controllers/html/sessions_controller_test.rb.tt +8 -8
- data/lib/generators/authentication/templates/test_unit/system/identity/emails_test.rb.tt +2 -2
- data/lib/generators/authentication/templates/test_unit/system/identity/password_resets_test.rb.tt +3 -3
- data/lib/generators/authentication/templates/test_unit/system/passwords_test.rb.tt +1 -1
- data/lib/generators/authentication/templates/test_unit/system/sessions_test.rb.tt +4 -4
- data/lib/generators/authentication/templates/test_unit/test_helper.rb.tt +4 -4
- data/lib/generators/authentication/templates/test_unit/{fixtures.yml.tt → users.yml.tt} +0 -0
- metadata +11 -11
- data/lib/generators/authentication/templates/mailers/identity_mailer.rb.tt +0 -19
@@ -2,9 +2,9 @@ require "test_helper"
|
|
2
2
|
|
3
3
|
class Identity::PasswordResetsControllerTest < ActionDispatch::IntegrationTest
|
4
4
|
setup do
|
5
|
-
|
6
|
-
@sid =
|
7
|
-
@sid_exp =
|
5
|
+
@user = users(:lazaro_nixon)
|
6
|
+
@sid = @user.signed_id(purpose: :password_reset, expires_in: 20.minutes)
|
7
|
+
@sid_exp = @user.signed_id(purpose: :password_reset, expires_in: 0.minutes)
|
8
8
|
end
|
9
9
|
|
10
10
|
test "should get new" do
|
@@ -18,8 +18,8 @@ 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
|
22
|
-
post identity_password_reset_url, params: { email:
|
21
|
+
assert_enqueued_email_with UserMailer, :password_reset_provision, args: { user: @user } do
|
22
|
+
post identity_password_reset_url, params: { email: @user.email }
|
23
23
|
end
|
24
24
|
|
25
25
|
assert_redirected_to sign_in_url
|
@@ -35,10 +35,10 @@ class Identity::PasswordResetsControllerTest < ActionDispatch::IntegrationTest
|
|
35
35
|
end
|
36
36
|
|
37
37
|
test "should not send a password reset email to a unverified email" do
|
38
|
-
|
38
|
+
@user.update! verified: false
|
39
39
|
|
40
40
|
assert_no_enqueued_emails do
|
41
|
-
post identity_password_reset_url, params: { email:
|
41
|
+
post identity_password_reset_url, params: { email: @user.email }
|
42
42
|
end
|
43
43
|
|
44
44
|
assert_redirected_to new_identity_password_reset_url
|
@@ -7,7 +7,7 @@ class RegistrationsControllerTest < ActionDispatch::IntegrationTest
|
|
7
7
|
end
|
8
8
|
|
9
9
|
test "should sign up" do
|
10
|
-
assert_difference("
|
10
|
+
assert_difference("User.count") do
|
11
11
|
post sign_up_url, params: { email: "lazaronixon@hey.com", password: "Secret1*3*5*", password_confirmation: "Secret1*3*5*" }
|
12
12
|
end
|
13
13
|
|
@@ -2,11 +2,11 @@ require "test_helper"
|
|
2
2
|
|
3
3
|
class SessionsControllerTest < ActionDispatch::IntegrationTest
|
4
4
|
setup do
|
5
|
-
|
5
|
+
@user = users(:lazaro_nixon)
|
6
6
|
end
|
7
7
|
|
8
8
|
test "should get index" do
|
9
|
-
sign_in_as
|
9
|
+
sign_in_as @user
|
10
10
|
|
11
11
|
get sessions_url
|
12
12
|
assert_response :success
|
@@ -18,8 +18,8 @@ class SessionsControllerTest < ActionDispatch::IntegrationTest
|
|
18
18
|
end
|
19
19
|
|
20
20
|
test "should sign in" do
|
21
|
-
post sign_in_url, params: { email:
|
22
|
-
assert_enqueued_email_with SessionMailer, :signed_in_notification, args: { session:
|
21
|
+
post sign_in_url, params: { email: @user.email, password: "Secret1*3*5*" }
|
22
|
+
assert_enqueued_email_with SessionMailer, :signed_in_notification, args: { session: @user.sessions.last }
|
23
23
|
|
24
24
|
assert_redirected_to root_url
|
25
25
|
|
@@ -28,8 +28,8 @@ class SessionsControllerTest < ActionDispatch::IntegrationTest
|
|
28
28
|
end
|
29
29
|
|
30
30
|
test "should not sign in with wrong credentials" do
|
31
|
-
post sign_in_url, params: { email:
|
32
|
-
assert_redirected_to sign_in_url(email_hint:
|
31
|
+
post sign_in_url, params: { email: @user.email, password: "SecretWrong1*3" }
|
32
|
+
assert_redirected_to sign_in_url(email_hint: @user.email)
|
33
33
|
assert_equal "That email or password is incorrect", flash[:alert]
|
34
34
|
|
35
35
|
get root_url
|
@@ -37,9 +37,9 @@ class SessionsControllerTest < ActionDispatch::IntegrationTest
|
|
37
37
|
end
|
38
38
|
|
39
39
|
test "should sign out" do
|
40
|
-
sign_in_as
|
40
|
+
sign_in_as @user
|
41
41
|
|
42
|
-
delete session_url(
|
42
|
+
delete session_url(@user.sessions.last)
|
43
43
|
assert_redirected_to sessions_url
|
44
44
|
|
45
45
|
follow_redirect!
|
@@ -2,7 +2,7 @@ require "application_system_test_case"
|
|
2
2
|
|
3
3
|
class Identity::EmailsTest < ApplicationSystemTestCase
|
4
4
|
setup do
|
5
|
-
|
5
|
+
@user = sign_in_as(users(:lazaro_nixon))
|
6
6
|
end
|
7
7
|
|
8
8
|
test "updating the email" do
|
@@ -16,7 +16,7 @@ class Identity::EmailsTest < ApplicationSystemTestCase
|
|
16
16
|
end
|
17
17
|
|
18
18
|
test "sending a verification email" do
|
19
|
-
|
19
|
+
@user.update! verified: false
|
20
20
|
|
21
21
|
click_on "Change email address"
|
22
22
|
click_on "Re-send verification email"
|
data/lib/generators/authentication/templates/test_unit/system/identity/password_resets_test.rb.tt
CHANGED
@@ -2,15 +2,15 @@ require "application_system_test_case"
|
|
2
2
|
|
3
3
|
class Identity::PasswordResetsTest < ApplicationSystemTestCase
|
4
4
|
setup do
|
5
|
-
|
6
|
-
@sid =
|
5
|
+
@user = users(:lazaro_nixon)
|
6
|
+
@sid = @user.signed_id(purpose: :password_reset, expires_in: 20.minutes)
|
7
7
|
end
|
8
8
|
|
9
9
|
test "sending a password reset email" do
|
10
10
|
visit sign_in_url
|
11
11
|
click_on "Forgot your password?"
|
12
12
|
|
13
|
-
fill_in "Email", with:
|
13
|
+
fill_in "Email", with: @user.email
|
14
14
|
click_on "Send password reset email"
|
15
15
|
|
16
16
|
assert_text "Check your email for reset instructions"
|
@@ -2,11 +2,11 @@ require "application_system_test_case"
|
|
2
2
|
|
3
3
|
class SessionsTest < ApplicationSystemTestCase
|
4
4
|
setup do
|
5
|
-
|
5
|
+
@user = users(:lazaro_nixon)
|
6
6
|
end
|
7
7
|
|
8
8
|
test "visiting the index" do
|
9
|
-
sign_in_as
|
9
|
+
sign_in_as @user
|
10
10
|
|
11
11
|
click_on "Devices & Sessions"
|
12
12
|
assert_selector "h1", text: "Sessions"
|
@@ -14,7 +14,7 @@ class SessionsTest < ApplicationSystemTestCase
|
|
14
14
|
|
15
15
|
test "signing in" do
|
16
16
|
visit sign_in_url
|
17
|
-
fill_in "Email", with:
|
17
|
+
fill_in "Email", with: @user.email
|
18
18
|
fill_in "Password", with: "Secret1*3*5*"
|
19
19
|
click_on "Sign in"
|
20
20
|
|
@@ -22,7 +22,7 @@ class SessionsTest < ApplicationSystemTestCase
|
|
22
22
|
end
|
23
23
|
|
24
24
|
test "signing out" do
|
25
|
-
sign_in_as
|
25
|
+
sign_in_as @user
|
26
26
|
|
27
27
|
click_on "Log out"
|
28
28
|
assert_text "That session has been logged out"
|
@@ -11,12 +11,12 @@ class ActiveSupport::TestCase
|
|
11
11
|
|
12
12
|
# Add more helper methods to be used by all tests here...
|
13
13
|
<%- if options.api? -%>
|
14
|
-
def sign_in_as(
|
15
|
-
post(sign_in_url, params: { email:
|
14
|
+
def sign_in_as(user)
|
15
|
+
post(sign_in_url, params: { email: user.email, password: "Secret1*3*5*" }); [user, response.headers["X-Session-Token"]]
|
16
16
|
end
|
17
17
|
<%- else -%>
|
18
|
-
def sign_in_as(
|
19
|
-
post(sign_in_url, params: { email:
|
18
|
+
def sign_in_as(user)
|
19
|
+
post(sign_in_url, params: { email: user.email, password: "Secret1*3*5*" }); user
|
20
20
|
end
|
21
21
|
<%- end -%>
|
22
22
|
end
|
File without changes
|
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.
|
4
|
+
version: 2.12.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-03-
|
11
|
+
date: 2022-03-28 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|
@@ -57,14 +57,10 @@ files:
|
|
57
57
|
- lib/generators/authentication/templates/controllers/html/sessions_controller.rb.tt
|
58
58
|
- lib/generators/authentication/templates/controllers/html/two_factor_authentication/challenges_controller.rb.tt
|
59
59
|
- lib/generators/authentication/templates/controllers/html/two_factor_authentication/totps_controller.rb.tt
|
60
|
-
- lib/generators/authentication/templates/erb/authentications/events/index.html.erb
|
60
|
+
- lib/generators/authentication/templates/erb/authentications/events/index.html.erb.tt
|
61
61
|
- lib/generators/authentication/templates/erb/identity/emails/edit.html.erb.tt
|
62
62
|
- lib/generators/authentication/templates/erb/identity/password_resets/edit.html.erb.tt
|
63
63
|
- lib/generators/authentication/templates/erb/identity/password_resets/new.html.erb.tt
|
64
|
-
- lib/generators/authentication/templates/erb/identity_mailer/email_verify_confirmation.html.erb.tt
|
65
|
-
- lib/generators/authentication/templates/erb/identity_mailer/email_verify_confirmation.text.erb.tt
|
66
|
-
- lib/generators/authentication/templates/erb/identity_mailer/password_reset_provision.html.erb.tt
|
67
|
-
- lib/generators/authentication/templates/erb/identity_mailer/password_reset_provision.text.erb.tt
|
68
64
|
- lib/generators/authentication/templates/erb/passwords/edit.html.erb.tt
|
69
65
|
- lib/generators/authentication/templates/erb/registrations/new.html.erb.tt
|
70
66
|
- lib/generators/authentication/templates/erb/session_mailer/signed_in_notification.html.erb.tt
|
@@ -74,16 +70,20 @@ files:
|
|
74
70
|
- lib/generators/authentication/templates/erb/sessions/sudos/new.html.erb.tt
|
75
71
|
- lib/generators/authentication/templates/erb/two_factor_authentication/challenges/new.html.erb.tt
|
76
72
|
- lib/generators/authentication/templates/erb/two_factor_authentication/totps/new.html.erb.tt
|
77
|
-
- lib/generators/authentication/templates/
|
73
|
+
- lib/generators/authentication/templates/erb/user_mailer/email_verify_confirmation.html.erb.tt
|
74
|
+
- lib/generators/authentication/templates/erb/user_mailer/email_verify_confirmation.text.erb.tt
|
75
|
+
- lib/generators/authentication/templates/erb/user_mailer/password_reset_provision.html.erb.tt
|
76
|
+
- lib/generators/authentication/templates/erb/user_mailer/password_reset_provision.text.erb.tt
|
78
77
|
- lib/generators/authentication/templates/mailers/session_mailer.rb.tt
|
78
|
+
- lib/generators/authentication/templates/mailers/user_mailer.rb.tt
|
79
79
|
- lib/generators/authentication/templates/migrations/create_events_migration.rb.tt
|
80
80
|
- lib/generators/authentication/templates/migrations/create_sessions_migration.rb.tt
|
81
|
-
- lib/generators/authentication/templates/migrations/
|
81
|
+
- lib/generators/authentication/templates/migrations/create_users_migration.rb.tt
|
82
82
|
- lib/generators/authentication/templates/models/current.rb.tt
|
83
83
|
- lib/generators/authentication/templates/models/event.rb.tt
|
84
84
|
- lib/generators/authentication/templates/models/locking.rb.tt
|
85
|
-
- lib/generators/authentication/templates/models/model.rb.tt
|
86
85
|
- lib/generators/authentication/templates/models/session.rb.tt
|
86
|
+
- lib/generators/authentication/templates/models/user.rb.tt
|
87
87
|
- lib/generators/authentication/templates/test_unit/application_system_test_case.rb.tt
|
88
88
|
- lib/generators/authentication/templates/test_unit/controllers/api/identity/email_verifications_controller_test.rb.tt
|
89
89
|
- lib/generators/authentication/templates/test_unit/controllers/api/identity/emails_controller_test.rb.tt
|
@@ -97,13 +97,13 @@ files:
|
|
97
97
|
- lib/generators/authentication/templates/test_unit/controllers/html/passwords_controller_test.rb.tt
|
98
98
|
- lib/generators/authentication/templates/test_unit/controllers/html/registrations_controller_test.rb.tt
|
99
99
|
- lib/generators/authentication/templates/test_unit/controllers/html/sessions_controller_test.rb.tt
|
100
|
-
- lib/generators/authentication/templates/test_unit/fixtures.yml.tt
|
101
100
|
- lib/generators/authentication/templates/test_unit/system/identity/emails_test.rb.tt
|
102
101
|
- lib/generators/authentication/templates/test_unit/system/identity/password_resets_test.rb.tt
|
103
102
|
- lib/generators/authentication/templates/test_unit/system/passwords_test.rb.tt
|
104
103
|
- lib/generators/authentication/templates/test_unit/system/registrations_test.rb.tt
|
105
104
|
- lib/generators/authentication/templates/test_unit/system/sessions_test.rb.tt
|
106
105
|
- lib/generators/authentication/templates/test_unit/test_helper.rb.tt
|
106
|
+
- lib/generators/authentication/templates/test_unit/users.yml.tt
|
107
107
|
homepage: https://github.com/lazaronixon/authentication-zero
|
108
108
|
licenses:
|
109
109
|
- MIT
|
@@ -1,19 +0,0 @@
|
|
1
|
-
class IdentityMailer < ApplicationMailer
|
2
|
-
def password_reset_provision
|
3
|
-
@<%= singular_table_name %> = params[:<%= singular_table_name %>]
|
4
|
-
@signed_id = @<%= singular_table_name %>.signed_id(purpose: :password_reset, expires_in: 20.minutes)
|
5
|
-
|
6
|
-
mail to: @<%= singular_table_name %>.email, subject: "Reset your password"
|
7
|
-
end
|
8
|
-
|
9
|
-
def email_verify_confirmation
|
10
|
-
@<%= singular_table_name %> = params[:<%= singular_table_name %>]
|
11
|
-
<%- if code_verifiable? -%>
|
12
|
-
@<%= singular_table_name %>.verification_code.value = rand.to_s[2..7]
|
13
|
-
<%- else -%>
|
14
|
-
@signed_id = @<%= singular_table_name %>.signed_id(purpose: @<%= singular_table_name %>.email, expires_in: 2.days)
|
15
|
-
<%- end -%>
|
16
|
-
|
17
|
-
mail to: @<%= singular_table_name %>.email, subject: "Verify your email"
|
18
|
-
end
|
19
|
-
end
|