authentication-zero 2.0.0 → 2.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/README.md +8 -7
  4. data/lib/authentication_zero/version.rb +1 -1
  5. data/lib/generators/authentication/authentication_generator.rb +7 -6
  6. data/lib/generators/authentication/templates/controllers/api/email_verifications_controller.rb.tt +18 -0
  7. data/lib/generators/authentication/templates/controllers/api/password_resets_controller.rb.tt +6 -6
  8. data/lib/generators/authentication/templates/controllers/api/registrations_controller.rb.tt +5 -1
  9. data/lib/generators/authentication/templates/controllers/api/sessions_controller.rb.tt +4 -4
  10. data/lib/generators/authentication/templates/controllers/html/email_verifications_controller.rb.tt +20 -0
  11. data/lib/generators/authentication/templates/controllers/html/emails_controller.rb.tt +2 -2
  12. data/lib/generators/authentication/templates/controllers/html/password_resets_controller.rb.tt +7 -7
  13. data/lib/generators/authentication/templates/controllers/html/passwords_controller.rb.tt +2 -2
  14. data/lib/generators/authentication/templates/controllers/html/registrations_controller.rb.tt +7 -9
  15. data/lib/generators/authentication/templates/controllers/html/sessions_controller.rb.tt +4 -4
  16. data/lib/generators/authentication/templates/erb/emails/edit.html.erb.tt +8 -2
  17. data/lib/generators/authentication/templates/erb/identity_mailer/email_verify_confirmation.html.erb.tt +11 -0
  18. data/lib/generators/authentication/templates/erb/identity_mailer/email_verify_confirmation.text.erb.tt +9 -0
  19. data/lib/generators/authentication/templates/erb/{password_mailer/reset.html.erb.tt → identity_mailer/password_reset_provision.html.erb.tt} +2 -2
  20. data/lib/generators/authentication/templates/erb/{password_mailer/reset.text.erb.tt → identity_mailer/password_reset_provision.text.erb.tt} +2 -2
  21. data/lib/generators/authentication/templates/erb/password_resets/edit.html.erb.tt +1 -1
  22. data/lib/generators/authentication/templates/erb/password_resets/new.html.erb.tt +1 -1
  23. data/lib/generators/authentication/templates/erb/passwords/edit.html.erb.tt +1 -1
  24. data/lib/generators/authentication/templates/erb/session_mailer/signed_in_notification.html.erb.tt +21 -0
  25. data/lib/generators/authentication/templates/erb/session_mailer/signed_in_notification.text.erb.tt +17 -0
  26. data/lib/generators/authentication/templates/erb/sessions/new.html.erb.tt +1 -1
  27. data/lib/generators/authentication/templates/mailers/identity_mailer.rb.tt +15 -0
  28. data/lib/generators/authentication/templates/mailers/session_mailer.rb.tt +6 -0
  29. data/lib/generators/authentication/templates/migrations/create_sessions_migration.rb.tt +1 -0
  30. data/lib/generators/authentication/templates/migrations/create_table_migration.rb.tt +2 -0
  31. data/lib/generators/authentication/templates/models/current.rb.tt +1 -1
  32. data/lib/generators/authentication/templates/models/model.rb.tt +8 -8
  33. data/lib/generators/authentication/templates/models/session.rb.tt +4 -0
  34. data/lib/generators/authentication/templates/test_unit/controllers/api/email_verifications_controller_test.rb.tt +36 -0
  35. data/lib/generators/authentication/templates/test_unit/controllers/api/emails_controller_test.rb.tt +2 -7
  36. data/lib/generators/authentication/templates/test_unit/controllers/api/password_resets_controller_test.rb.tt +18 -7
  37. data/lib/generators/authentication/templates/test_unit/controllers/api/passwords_controller_test.rb.tt +2 -7
  38. data/lib/generators/authentication/templates/test_unit/controllers/api/registrations_controller_test.rb.tt +15 -0
  39. data/lib/generators/authentication/templates/test_unit/controllers/api/sessions_controller_test.rb.tt +2 -0
  40. data/lib/generators/authentication/templates/test_unit/controllers/html/email_verifications_controller_test.rb.tt +35 -0
  41. data/lib/generators/authentication/templates/test_unit/controllers/html/emails_controller_test.rb.tt +5 -10
  42. data/lib/generators/authentication/templates/test_unit/controllers/html/password_resets_controller_test.rb.tt +22 -11
  43. data/lib/generators/authentication/templates/test_unit/controllers/html/passwords_controller_test.rb.tt +5 -10
  44. data/lib/generators/authentication/templates/test_unit/controllers/html/registrations_controller_test.rb.tt +15 -3
  45. data/lib/generators/authentication/templates/test_unit/controllers/html/sessions_controller_test.rb.tt +4 -2
  46. data/lib/generators/authentication/templates/test_unit/fixtures.yml.tt +1 -0
  47. data/lib/generators/authentication/templates/test_unit/sessions.yml.tt +1 -1
  48. data/lib/generators/authentication/templates/test_unit/system/emails_test.rb.tt +11 -2
  49. data/lib/generators/authentication/templates/test_unit/system/password_resets_test.rb.tt +2 -2
  50. data/lib/generators/authentication/templates/test_unit/system/passwords_test.rb.tt +2 -2
  51. data/lib/generators/authentication/templates/test_unit/system/registrations_test.rb.tt +20 -0
  52. metadata +14 -16
  53. data/lib/generators/authentication/templates/controllers/api/cancellations_controller.rb.tt +0 -5
  54. data/lib/generators/authentication/templates/controllers/html/cancellations_controller.rb.tt +0 -9
  55. data/lib/generators/authentication/templates/erb/cancellations/new.html.erb.tt +0 -11
  56. data/lib/generators/authentication/templates/erb/email_mailer/changed.html.erb.tt +0 -11
  57. data/lib/generators/authentication/templates/erb/email_mailer/changed.text.erb.tt +0 -9
  58. data/lib/generators/authentication/templates/erb/password_mailer/changed.html.erb.tt +0 -7
  59. data/lib/generators/authentication/templates/erb/password_mailer/changed.text.erb.tt +0 -5
  60. data/lib/generators/authentication/templates/mailers/email_mailer.rb.tt +0 -6
  61. data/lib/generators/authentication/templates/mailers/password_mailer.rb.tt +0 -10
  62. data/lib/generators/authentication/templates/test_unit/controllers/api/cancellations_controller_test.rb.tt +0 -20
  63. data/lib/generators/authentication/templates/test_unit/controllers/html/cancellations_controller_test.rb.tt +0 -24
  64. data/lib/generators/authentication/templates/test_unit/system/cancellations_test.rb.tt +0 -23
@@ -6,17 +6,12 @@ class EmailsControllerTest < ActionDispatch::IntegrationTest
6
6
  end
7
7
 
8
8
  test "should update email" do
9
- assert_enqueued_email_with EmailMailer, :changed, args: { change: [@<%= singular_table_name %>.email, "new_email@hey.com"] } do
10
- patch emails_url, params: { current_password: "secret123", email: "new_email@hey.com" }, headers: { "Authorization" => "Bearer #{@token}" }
11
- end
12
-
9
+ patch email_url, params: { current_password: "secret123", email: "new_email@hey.com" }, headers: { "Authorization" => "Bearer #{@token}" }
13
10
  assert_response :success
14
11
  end
15
12
 
16
13
  test "should not update email with wrong current password" do
17
- assert_no_enqueued_emails do
18
- patch emails_url, params: { current_password: "wrong_password", email: @<%= singular_table_name %>.email }, headers: { "Authorization" => "Bearer #{@token}" }
19
- end
14
+ patch email_url, params: { current_password: "wrong_password", email: @<%= singular_table_name %>.email }, headers: { "Authorization" => "Bearer #{@token}" }
20
15
 
21
16
  assert_response :bad_request
22
17
  assert_equal "The current password you entered is incorrect", response.parsed_body["error"]
@@ -8,8 +8,8 @@ class PasswordResetsControllerTest < ActionDispatch::IntegrationTest
8
8
  end
9
9
 
10
10
  test "should send a password reset email" do
11
- assert_enqueued_email_with PasswordMailer, :reset, args: { <%= singular_table_name %>: @<%= singular_table_name %> } do
12
- post password_resets_url, params: { email: @<%= singular_table_name %>.email }
11
+ assert_enqueued_email_with IdentityMailer, :password_reset_provision, args: { <%= singular_table_name %>: @<%= singular_table_name %> } do
12
+ post password_reset_url, params: { email: @<%= singular_table_name %>.email }
13
13
  end
14
14
 
15
15
  assert_response :no_content
@@ -17,22 +17,33 @@ class PasswordResetsControllerTest < ActionDispatch::IntegrationTest
17
17
 
18
18
  test "should not send a password reset email to a nonexistent email" do
19
19
  assert_no_enqueued_emails do
20
- post password_resets_url, params: { email: "invalid_email@hey.com" }
20
+ post password_reset_url, params: { email: "invalid_email@hey.com" }
21
21
  end
22
22
 
23
23
  assert_response :not_found
24
- assert_equal "Sorry, we didn't recognize that email address", response.parsed_body["error"]
24
+ assert_equal "You can't reset your password until you verify your email", response.parsed_body["error"]
25
+ end
26
+
27
+ test "should not send a password reset email to a unverified email" do
28
+ @<%= singular_table_name %>.update!(verified: false)
29
+
30
+ assert_no_enqueued_emails do
31
+ post password_reset_url, params: { email: @<%= singular_table_name %>.email }
32
+ end
33
+
34
+ assert_response :not_found
35
+ assert_equal "You can't reset your password until you verify your email", response.parsed_body["error"]
25
36
  end
26
37
 
27
38
  test "should update password" do
28
- patch password_resets_url, params: { token: @sid, password: "new_password", password_confirmation: "new_password" }
39
+ patch password_reset_url, params: { token: @sid, password: "new_password", password_confirmation: "new_password" }
29
40
  assert_response :success
30
41
  end
31
42
 
32
43
  test "should not update password with expired token" do
33
- patch password_resets_url, params: { token: @sid_exp, password: "new_password", password_confirmation: "new_password" }
44
+ patch password_reset_url, params: { token: @sid_exp, password: "new_password", password_confirmation: "new_password" }
34
45
 
35
46
  assert_response :bad_request
36
- assert_equal "Your token has expired, please request a new one", response.parsed_body["error"]
47
+ assert_equal "That password reset link is invalid", response.parsed_body["error"]
37
48
  end
38
49
  end
@@ -6,17 +6,12 @@ class PasswordsControllerTest < ActionDispatch::IntegrationTest
6
6
  end
7
7
 
8
8
  test "should update password" do
9
- assert_enqueued_email_with PasswordMailer, :changed, args: { <%= singular_table_name %>: @<%= singular_table_name %> } do
10
- patch passwords_url, params: { current_password: "secret123", password: "new_password", password_confirmation: "new_password" }, headers: { "Authorization" => "Bearer #{@token}" }
11
- end
12
-
9
+ patch password_url, params: { current_password: "secret123", password: "new_password", password_confirmation: "new_password" }, headers: { "Authorization" => "Bearer #{@token}" }
13
10
  assert_response :success
14
11
  end
15
12
 
16
13
  test "should not update password with wrong current password" do
17
- assert_no_enqueued_emails do
18
- patch passwords_url, params: { current_password: "wrong_password", password: "new_password", password_confirmation: "new_password" }, headers: { "Authorization" => "Bearer #{@token}" }
19
- end
14
+ patch password_url, params: { current_password: "wrong_password", password: "new_password", password_confirmation: "new_password" }, headers: { "Authorization" => "Bearer #{@token}" }
20
15
 
21
16
  assert_response :bad_request
22
17
  assert_equal "The current password you entered is incorrect", response.parsed_body["error"]
@@ -8,4 +8,19 @@ class RegistrationsControllerTest < ActionDispatch::IntegrationTest
8
8
 
9
9
  assert_response :created
10
10
  end
11
+
12
+ test "should destroy account" do
13
+ @<%= singular_table_name %>, @token = sign_in_as(<%= table_name %>(:lazaro_nixon))
14
+
15
+ assert_difference("<%= class_name %>.count", -1) do
16
+ delete registration_url, headers: { "Authorization" => "Bearer #{@token}" }
17
+ end
18
+
19
+ assert_response :no_content
20
+ end
21
+
22
+ def sign_in_as(<%= singular_table_name %>)
23
+ post(sign_in_url, params: { email: <%= singular_table_name %>.email, password: "secret123" })
24
+ [<%= singular_table_name %>, response.headers["X-Session-Token"]]
25
+ end
11
26
  end
@@ -17,6 +17,8 @@ class SessionsControllerTest < ActionDispatch::IntegrationTest
17
17
 
18
18
  test "should sign in" do
19
19
  post sign_in_url, params: { email: @<%= singular_table_name %>.email, password: "secret123" }
20
+
21
+ assert_enqueued_email_with SessionMailer, :signed_in_notification, args: { session: @<%= singular_table_name %>.sessions.last }
20
22
  assert_response :created
21
23
  end
22
24
 
@@ -0,0 +1,35 @@
1
+ require "test_helper"
2
+
3
+ class EmailVerificationsControllerTest < ActionDispatch::IntegrationTest
4
+ setup do
5
+ @<%= singular_table_name %> = sign_in_as(<%= table_name %>(:lazaro_nixon))
6
+ @sid = @<%= singular_table_name %>.signed_id(purpose: "verify_#{@<%= singular_table_name %>.email}", expires_in: 20.minutes)
7
+ @sid_exp = @<%= singular_table_name %>.signed_id(purpose: "verify_#{@<%= singular_table_name %>.email}", expires_in: 0.minutes)
8
+
9
+ @<%= singular_table_name %>.update! verified: false
10
+ end
11
+
12
+ test "should send a verification email" do
13
+ assert_enqueued_email_with IdentityMailer, :email_verify_confirmation, args: { <%= singular_table_name %>: @<%= singular_table_name %> } do
14
+ post email_verification_url
15
+ end
16
+
17
+ assert_redirected_to root_path
18
+ end
19
+
20
+ test "should verify email" do
21
+ get edit_email_verification_url(token: @sid, email: @<%= singular_table_name %>.email)
22
+ assert_redirected_to root_path
23
+ end
24
+
25
+ test "should not verify email with expired token" do
26
+ get edit_email_verification_url(token: @sid_exp, email: @<%= singular_table_name %>.email)
27
+
28
+ assert_redirected_to edit_email_path
29
+ assert_equal "That email verification link is invalid", flash[:alert]
30
+ end
31
+
32
+ def sign_in_as(<%= singular_table_name %>)
33
+ post(sign_in_url, params: { email: <%= singular_table_name %>.email, password: "secret123" }); <%= singular_table_name %>
34
+ end
35
+ end
@@ -6,28 +6,23 @@ class EmailsControllerTest < ActionDispatch::IntegrationTest
6
6
  end
7
7
 
8
8
  test "should get edit" do
9
- get edit_emails_url
9
+ get edit_email_url
10
10
  assert_response :success
11
11
  end
12
12
 
13
13
  test "should update email" do
14
- assert_enqueued_email_with EmailMailer, :changed, args: { change: [@<%= singular_table_name %>.email, "new_email@hey.com"] } do
15
- patch emails_url, params: { current_password: "secret123", <%= singular_table_name %>: { email: "new_email@hey.com" } }
16
- end
17
-
14
+ patch email_url, params: { current_password: "secret123", <%= singular_table_name %>: { email: "new_email@hey.com" } }
18
15
  assert_redirected_to root_path
19
16
  end
20
17
 
21
18
  test "should not update email with wrong current password" do
22
- assert_no_enqueued_emails do
23
- patch emails_url, params: { current_password: "wrong_password", <%= singular_table_name %>: { email: @<%= singular_table_name %>.email } }
24
- end
19
+ patch email_url, params: { current_password: "wrong_password", <%= singular_table_name %>: { email: @<%= singular_table_name %>.email } }
25
20
 
26
- assert_redirected_to edit_emails_path
21
+ assert_redirected_to edit_email_path
27
22
  assert_equal "The current password you entered is incorrect", flash[:alert]
28
23
  end
29
24
 
30
25
  def sign_in_as(<%= singular_table_name %>)
31
- post(sign_in_url, params: { email: <%= singular_table_name %>.email, password: "secret123" }); user
26
+ post(sign_in_url, params: { email: <%= singular_table_name %>.email, password: "secret123" }); <%= singular_table_name %>
32
27
  end
33
28
  end
@@ -8,18 +8,18 @@ class PasswordResetsControllerTest < ActionDispatch::IntegrationTest
8
8
  end
9
9
 
10
10
  test "should get new" do
11
- get new_password_resets_url
11
+ get new_password_reset_url
12
12
  assert_response :success
13
13
  end
14
14
 
15
15
  test "should get edit" do
16
- get edit_password_resets_url(token: @sid)
16
+ get edit_password_reset_url(token: @sid)
17
17
  assert_response :success
18
18
  end
19
19
 
20
20
  test "should send a password reset email" do
21
- assert_enqueued_email_with PasswordMailer, :reset, args: { <%= singular_table_name %>: @<%= singular_table_name %> } do
22
- post password_resets_url, params: { email: @<%= singular_table_name %>.email }
21
+ assert_enqueued_email_with IdentityMailer, :password_reset_provision, args: { <%= singular_table_name %>: @<%= singular_table_name %> } do
22
+ post password_reset_url, params: { email: @<%= singular_table_name %>.email }
23
23
  end
24
24
 
25
25
  assert_redirected_to sign_in_path
@@ -27,22 +27,33 @@ class PasswordResetsControllerTest < ActionDispatch::IntegrationTest
27
27
 
28
28
  test "should not send a password reset email to a nonexistent email" do
29
29
  assert_no_enqueued_emails do
30
- post password_resets_url, params: { email: "invalid_email@hey.com" }
30
+ post password_reset_url, params: { email: "invalid_email@hey.com" }
31
31
  end
32
32
 
33
- assert_redirected_to new_password_resets_url
34
- assert_equal "Sorry, we didn't recognize that email address", flash[:alert]
33
+ assert_redirected_to new_password_reset_url
34
+ assert_equal "You can't reset your password until you verify your email", flash[:alert]
35
+ end
36
+
37
+ test "should not send a password reset email to a unverified email" do
38
+ @<%= singular_table_name %>.update!(verified: false)
39
+
40
+ assert_no_enqueued_emails do
41
+ post password_reset_url, params: { email: @<%= singular_table_name %>.email }
42
+ end
43
+
44
+ assert_redirected_to new_password_reset_url
45
+ assert_equal "You can't reset your password until you verify your email", flash[:alert]
35
46
  end
36
47
 
37
48
  test "should update password" do
38
- patch password_resets_url, params: { token: @sid, <%= singular_table_name %>: { password: "new_password", password_confirmation: "new_password" } }
49
+ patch password_reset_url, params: { token: @sid, <%= singular_table_name %>: { password: "new_password", password_confirmation: "new_password" } }
39
50
  assert_redirected_to sign_in_path
40
51
  end
41
52
 
42
53
  test "should not update password with expired token" do
43
- patch password_resets_url, params: { token: @sid_exp, password: "new_password", password_confirmation: "new_password" }
54
+ patch password_reset_url, params: { token: @sid_exp, password: "new_password", password_confirmation: "new_password" }
44
55
 
45
- assert_redirected_to new_password_resets_path
46
- assert_equal "Your token has expired, please request a new one", flash[:alert]
56
+ assert_redirected_to new_password_reset_path
57
+ assert_equal "That password reset link is invalid", flash[:alert]
47
58
  end
48
59
  end
@@ -6,28 +6,23 @@ class PasswordsControllerTest < ActionDispatch::IntegrationTest
6
6
  end
7
7
 
8
8
  test "should get edit" do
9
- get edit_passwords_url
9
+ get edit_password_url
10
10
  assert_response :success
11
11
  end
12
12
 
13
13
  test "should update password" do
14
- assert_enqueued_email_with PasswordMailer, :changed, args: { <%= singular_table_name %>: @<%= singular_table_name %> } do
15
- patch passwords_url, params: { current_password: "secret123", <%= singular_table_name %>: { password: "new_password", password_confirmation: "new_password" } }
16
- end
17
-
14
+ patch password_url, params: { current_password: "secret123", <%= singular_table_name %>: { password: "new_password", password_confirmation: "new_password" } }
18
15
  assert_redirected_to root_path
19
16
  end
20
17
 
21
18
  test "should not update password with wrong current password" do
22
- assert_no_enqueued_emails do
23
- patch passwords_url, params: { current_password: "wrong_password", <%= singular_table_name %>: { password: "new_password", password_confirmation: "new_password" } }
24
- end
19
+ patch password_url, params: { current_password: "wrong_password", <%= singular_table_name %>: { password: "new_password", password_confirmation: "new_password" } }
25
20
 
26
- assert_redirected_to edit_passwords_path
21
+ assert_redirected_to edit_password_path
27
22
  assert_equal "The current password you entered is incorrect", flash[:alert]
28
23
  end
29
24
 
30
25
  def sign_in_as(<%= singular_table_name %>)
31
- post(sign_in_url, params: { email: <%= singular_table_name %>.email, password: "secret123" }); user
26
+ post(sign_in_url, params: { email: <%= singular_table_name %>.email, password: "secret123" }); <%= singular_table_name %>
32
27
  end
33
28
  end
@@ -10,9 +10,21 @@ class RegistrationsControllerTest < ActionDispatch::IntegrationTest
10
10
  assert_difference("<%= class_name %>.count") do
11
11
  post sign_up_url, params: { <%= singular_table_name %>: { email: "lazaronixon@hey.com", password: "secret123", password_confirmation: "secret123" } }
12
12
  end
13
- assert_redirected_to root_url
14
13
 
15
- follow_redirect!
16
- assert_response :success
14
+ assert_redirected_to sign_in_url
15
+ end
16
+
17
+ test "should destroy account" do
18
+ sign_in_as <%= table_name %>(:lazaro_nixon)
19
+
20
+ assert_difference("<%= class_name %>.count", -1) do
21
+ delete registration_path
22
+ end
23
+
24
+ assert_redirected_to sign_in_url
25
+ end
26
+
27
+ def sign_in_as(<%= singular_table_name %>)
28
+ post(sign_in_url, params: { email: <%= singular_table_name %>.email, password: "secret123" }); <%= singular_table_name %>
17
29
  end
18
30
  end
@@ -19,6 +19,8 @@ class SessionsControllerTest < ActionDispatch::IntegrationTest
19
19
 
20
20
  test "should sign in" do
21
21
  post sign_in_url, params: { email: @<%= singular_table_name %>.email, password: "secret123" }
22
+ assert_enqueued_email_with SessionMailer, :signed_in_notification, args: { session: @<%= singular_table_name %>.sessions.last }
23
+
22
24
  assert_redirected_to root_url
23
25
 
24
26
  get root_url
@@ -28,7 +30,7 @@ class SessionsControllerTest < ActionDispatch::IntegrationTest
28
30
  test "should not sign in with wrong credentials" do
29
31
  post sign_in_url, params: { email: @<%= singular_table_name %>.email, password: "wrong_password" }
30
32
  assert_redirected_to sign_in_url(email_hint: @<%= singular_table_name %>.email)
31
- assert_equal "Invalid email or password", flash[:alert]
33
+ assert_equal "That email or password is incorrect", flash[:alert]
32
34
 
33
35
  get root_url
34
36
  assert_redirected_to sign_in_path
@@ -45,6 +47,6 @@ class SessionsControllerTest < ActionDispatch::IntegrationTest
45
47
  end
46
48
 
47
49
  def sign_in_as(<%= singular_table_name %>)
48
- post(sign_in_url, params: { email: <%= singular_table_name %>.email, password: "secret123" }); user
50
+ post(sign_in_url, params: { email: <%= singular_table_name %>.email, password: "secret123" }); <%= singular_table_name %>
49
51
  end
50
52
  end
@@ -3,3 +3,4 @@
3
3
  lazaro_nixon:
4
4
  email: lazaronixon@hotmail.com
5
5
  password_digest: <%%= BCrypt::Password.create("secret123") %>
6
+ verified: true
@@ -1,6 +1,6 @@
1
1
  # Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
2
2
 
3
3
  lazaro_nixon_ios:
4
- user: lazaro_nixon
4
+ <%= singular_table_name %>: lazaro_nixon
5
5
  user_agent: Device iOS
6
6
  ip_address: 127.0.0.1
@@ -12,7 +12,16 @@ class EmailsTest < ApplicationSystemTestCase
12
12
  fill_in "New email", with: "new_email@hey.com"
13
13
  click_on "Save changes"
14
14
 
15
- assert_text "Your email has been changed successfully"
15
+ assert_text "Your email has been changed"
16
+ end
17
+
18
+ test "sending a verification email" do
19
+ @<%= singular_table_name %>.update! verified: false
20
+
21
+ click_on "Change email"
22
+ click_on "Re-send verification email"
23
+
24
+ assert_text "We sent a verification email to your email address"
16
25
  end
17
26
 
18
27
  def sign_in_as(<%= singular_table_name %>)
@@ -22,5 +31,5 @@ class EmailsTest < ApplicationSystemTestCase
22
31
  click_on "Sign in"
23
32
 
24
33
  return <%= singular_table_name %>
25
- end
34
+ end
26
35
  end
@@ -13,11 +13,11 @@ class PasswordResetsTest < ApplicationSystemTestCase
13
13
  fill_in "Email", with: @<%= singular_table_name %>.email
14
14
  click_on "Send password reset email"
15
15
 
16
- assert_text "You will receive an email with instructions on how to reset your password in a few minutes"
16
+ assert_text "Check your email for reset instructions"
17
17
  end
18
18
 
19
19
  test "updating password" do
20
- visit edit_password_resets_url(token: @sid)
20
+ visit edit_password_reset_url(token: @sid)
21
21
 
22
22
  fill_in "New password", with: "new_password"
23
23
  fill_in "Confirm new password", with: "new_password"
@@ -13,7 +13,7 @@ class PasswordsTest < ApplicationSystemTestCase
13
13
  fill_in "Confirm new password", with: "new_password"
14
14
  click_on "Save changes"
15
15
 
16
- assert_text "Your password has been changed successfully"
16
+ assert_text "Your password has been changed"
17
17
  end
18
18
 
19
19
  def sign_in_as(<%= singular_table_name %>)
@@ -23,5 +23,5 @@ class PasswordsTest < ApplicationSystemTestCase
23
23
  click_on "Sign in"
24
24
 
25
25
  return <%= singular_table_name %>
26
- end
26
+ end
27
27
  end
@@ -1,6 +1,10 @@
1
1
  require "application_system_test_case"
2
2
 
3
3
  class RegistrationsTest < ApplicationSystemTestCase
4
+ setup do
5
+ @<%= singular_table_name %> = <%= table_name %>(:lazaro_nixon)
6
+ end
7
+
4
8
  test "signing up" do
5
9
  visit sign_in_url
6
10
  click_on "Sign up"
@@ -12,4 +16,20 @@ class RegistrationsTest < ApplicationSystemTestCase
12
16
 
13
17
  assert_text "Welcome! You have signed up successfully"
14
18
  end
19
+
20
+ test "cancelling my account" do
21
+ sign_in_as @<%= singular_table_name %>
22
+ click_on "Cancel my account"
23
+
24
+ assert_text "Your account is closed"
25
+ end
26
+
27
+ def sign_in_as(<%= singular_table_name %>)
28
+ visit sign_in_url
29
+ fill_in :email, with: <%= singular_table_name %>.email
30
+ fill_in :password, with: "secret123"
31
+ click_on "Sign in"
32
+
33
+ return <%= singular_table_name %>
34
+ end
15
35
  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.0.0
4
+ version: 2.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nixon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-02-23 00:00:00.000000000 Z
11
+ date: 2022-02-24 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email:
@@ -31,46 +31,45 @@ files:
31
31
  - lib/authentication_zero/version.rb
32
32
  - lib/generators/authentication/USAGE
33
33
  - lib/generators/authentication/authentication_generator.rb
34
- - lib/generators/authentication/templates/controllers/api/cancellations_controller.rb.tt
34
+ - lib/generators/authentication/templates/controllers/api/email_verifications_controller.rb.tt
35
35
  - lib/generators/authentication/templates/controllers/api/emails_controller.rb.tt
36
36
  - lib/generators/authentication/templates/controllers/api/password_resets_controller.rb.tt
37
37
  - lib/generators/authentication/templates/controllers/api/passwords_controller.rb.tt
38
38
  - lib/generators/authentication/templates/controllers/api/registrations_controller.rb.tt
39
39
  - lib/generators/authentication/templates/controllers/api/sessions_controller.rb.tt
40
- - lib/generators/authentication/templates/controllers/html/cancellations_controller.rb.tt
40
+ - lib/generators/authentication/templates/controllers/html/email_verifications_controller.rb.tt
41
41
  - lib/generators/authentication/templates/controllers/html/emails_controller.rb.tt
42
42
  - lib/generators/authentication/templates/controllers/html/password_resets_controller.rb.tt
43
43
  - lib/generators/authentication/templates/controllers/html/passwords_controller.rb.tt
44
44
  - lib/generators/authentication/templates/controllers/html/registrations_controller.rb.tt
45
45
  - lib/generators/authentication/templates/controllers/html/sessions_controller.rb.tt
46
- - lib/generators/authentication/templates/erb/cancellations/new.html.erb.tt
47
- - lib/generators/authentication/templates/erb/email_mailer/changed.html.erb.tt
48
- - lib/generators/authentication/templates/erb/email_mailer/changed.text.erb.tt
49
46
  - lib/generators/authentication/templates/erb/emails/edit.html.erb.tt
50
- - lib/generators/authentication/templates/erb/password_mailer/changed.html.erb.tt
51
- - lib/generators/authentication/templates/erb/password_mailer/changed.text.erb.tt
52
- - lib/generators/authentication/templates/erb/password_mailer/reset.html.erb.tt
53
- - lib/generators/authentication/templates/erb/password_mailer/reset.text.erb.tt
47
+ - lib/generators/authentication/templates/erb/identity_mailer/email_verify_confirmation.html.erb.tt
48
+ - lib/generators/authentication/templates/erb/identity_mailer/email_verify_confirmation.text.erb.tt
49
+ - lib/generators/authentication/templates/erb/identity_mailer/password_reset_provision.html.erb.tt
50
+ - lib/generators/authentication/templates/erb/identity_mailer/password_reset_provision.text.erb.tt
54
51
  - lib/generators/authentication/templates/erb/password_resets/edit.html.erb.tt
55
52
  - lib/generators/authentication/templates/erb/password_resets/new.html.erb.tt
56
53
  - lib/generators/authentication/templates/erb/passwords/edit.html.erb.tt
57
54
  - lib/generators/authentication/templates/erb/registrations/new.html.erb.tt
55
+ - lib/generators/authentication/templates/erb/session_mailer/signed_in_notification.html.erb.tt
56
+ - lib/generators/authentication/templates/erb/session_mailer/signed_in_notification.text.erb.tt
58
57
  - lib/generators/authentication/templates/erb/sessions/index.html.erb.tt
59
58
  - lib/generators/authentication/templates/erb/sessions/new.html.erb.tt
60
- - lib/generators/authentication/templates/mailers/email_mailer.rb.tt
61
- - lib/generators/authentication/templates/mailers/password_mailer.rb.tt
59
+ - lib/generators/authentication/templates/mailers/identity_mailer.rb.tt
60
+ - lib/generators/authentication/templates/mailers/session_mailer.rb.tt
62
61
  - lib/generators/authentication/templates/migrations/create_sessions_migration.rb.tt
63
62
  - lib/generators/authentication/templates/migrations/create_table_migration.rb.tt
64
63
  - lib/generators/authentication/templates/models/current.rb.tt
65
64
  - lib/generators/authentication/templates/models/model.rb.tt
66
65
  - lib/generators/authentication/templates/models/session.rb.tt
67
- - lib/generators/authentication/templates/test_unit/controllers/api/cancellations_controller_test.rb.tt
66
+ - lib/generators/authentication/templates/test_unit/controllers/api/email_verifications_controller_test.rb.tt
68
67
  - lib/generators/authentication/templates/test_unit/controllers/api/emails_controller_test.rb.tt
69
68
  - lib/generators/authentication/templates/test_unit/controllers/api/password_resets_controller_test.rb.tt
70
69
  - lib/generators/authentication/templates/test_unit/controllers/api/passwords_controller_test.rb.tt
71
70
  - lib/generators/authentication/templates/test_unit/controllers/api/registrations_controller_test.rb.tt
72
71
  - lib/generators/authentication/templates/test_unit/controllers/api/sessions_controller_test.rb.tt
73
- - lib/generators/authentication/templates/test_unit/controllers/html/cancellations_controller_test.rb.tt
72
+ - lib/generators/authentication/templates/test_unit/controllers/html/email_verifications_controller_test.rb.tt
74
73
  - lib/generators/authentication/templates/test_unit/controllers/html/emails_controller_test.rb.tt
75
74
  - lib/generators/authentication/templates/test_unit/controllers/html/password_resets_controller_test.rb.tt
76
75
  - lib/generators/authentication/templates/test_unit/controllers/html/passwords_controller_test.rb.tt
@@ -78,7 +77,6 @@ files:
78
77
  - lib/generators/authentication/templates/test_unit/controllers/html/sessions_controller_test.rb.tt
79
78
  - lib/generators/authentication/templates/test_unit/fixtures.yml.tt
80
79
  - lib/generators/authentication/templates/test_unit/sessions.yml.tt
81
- - lib/generators/authentication/templates/test_unit/system/cancellations_test.rb.tt
82
80
  - lib/generators/authentication/templates/test_unit/system/emails_test.rb.tt
83
81
  - lib/generators/authentication/templates/test_unit/system/password_resets_test.rb.tt
84
82
  - lib/generators/authentication/templates/test_unit/system/passwords_test.rb.tt
@@ -1,5 +0,0 @@
1
- class CancellationsController < ApplicationController
2
- def create
3
- Current.<%= singular_table_name %>.destroy
4
- end
5
- end
@@ -1,9 +0,0 @@
1
- class CancellationsController < ApplicationController
2
- def new
3
- end
4
-
5
- def create
6
- Current.<%= singular_table_name %>.destroy
7
- redirect_to sign_in_path, notice: "Bye! Your account has been successfully cancelled"
8
- end
9
- end
@@ -1,11 +0,0 @@
1
- <h1>Want to close your account?</h1>
2
-
3
- <p>Your account will be immediately closed. You won't be able to sign in anymore.</p>
4
- <p>Your data will be permanently deleted from our servers.</p>
5
- <p><%%= link_to "Back", root_path %></p>
6
-
7
- <br>
8
-
9
- <div>
10
- <%%= button_to "OK, close my account", cancellations_path %>
11
- </div>
@@ -1,11 +0,0 @@
1
- <p>Hey there,</p>
2
-
3
- <p>We just wanted to confirm that your email address has been updated.</p>
4
-
5
- <p><strong>Before, it was: <%%= @previous_email %></strong></p>
6
-
7
- <p><strong>Now it is set to: <%%= @current_email %></strong></p>
8
-
9
- <hr>
10
-
11
- <p>If you didn't make this change, someone else may have access to your account. If you think that may be the case, please reply to this email and our support team will help you out.</p>
@@ -1,9 +0,0 @@
1
- Hey there,
2
-
3
- We just wanted to confirm that your email address has been updated.
4
-
5
- Before, it was: <%%= @previous_email %>
6
-
7
- Now it is set to: <%%= @current_email %>
8
-
9
- If you didn't make this change, someone else may have access to your account. If you think that may be the case, please reply to this email and our support team will help you out.
@@ -1,7 +0,0 @@
1
- <p>Hey there,</p>
2
-
3
- <p>We just wanted to confirm that your password has been updated.</p>
4
-
5
- <hr>
6
-
7
- <p>If you didn't make this change, someone else may have access to your account. If you think that may be the case, please reply to this email and our support team will help you out.</p>
@@ -1,5 +0,0 @@
1
- Hey there,
2
-
3
- We just wanted to confirm that your password has been updated.
4
-
5
- If you didn't make this change, someone else may have access to your account. If you think that may be the case, please reply to this email and our support team will help you out.
@@ -1,6 +0,0 @@
1
- class EmailMailer < ApplicationMailer
2
- def changed
3
- @previous_email, @current_email = params[:change]
4
- mail to: @previous_email
5
- end
6
- end
@@ -1,10 +0,0 @@
1
- class PasswordMailer < ApplicationMailer
2
- def changed
3
- mail to: params[:<%= singular_table_name %>].email
4
- end
5
-
6
- def reset
7
- @signed_id = params[:<%= singular_table_name %>].signed_id(purpose: :password_reset, expires_in: 20.minutes)
8
- mail to: params[:<%= singular_table_name %>].email
9
- end
10
- end