authentication-zero 1.0.2 → 2.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/README.md +9 -7
  4. data/lib/authentication_zero/version.rb +1 -1
  5. data/lib/generators/authentication/authentication_generator.rb +20 -13
  6. data/lib/generators/authentication/templates/controllers/api/password_resets_controller.rb.tt +1 -5
  7. data/lib/generators/authentication/templates/controllers/api/sessions_controller.rb.tt +26 -4
  8. data/lib/generators/authentication/templates/controllers/html/cancellations_controller.rb.tt +1 -1
  9. data/lib/generators/authentication/templates/controllers/html/emails_controller.rb.tt +2 -2
  10. data/lib/generators/authentication/templates/controllers/html/password_resets_controller.rb.tt +3 -3
  11. data/lib/generators/authentication/templates/controllers/html/passwords_controller.rb.tt +2 -2
  12. data/lib/generators/authentication/templates/controllers/html/registrations_controller.rb.tt +1 -2
  13. data/lib/generators/authentication/templates/controllers/html/sessions_controller.rb.tt +21 -9
  14. data/lib/generators/authentication/templates/erb/cancellations/new.html.erb.tt +1 -1
  15. data/lib/generators/authentication/templates/erb/emails/edit.html.erb.tt +1 -1
  16. data/lib/generators/authentication/templates/erb/password_mailer/reset.html.erb.tt +1 -1
  17. data/lib/generators/authentication/templates/erb/password_mailer/reset.text.erb.tt +1 -1
  18. data/lib/generators/authentication/templates/erb/password_resets/edit.html.erb.tt +1 -1
  19. data/lib/generators/authentication/templates/erb/password_resets/new.html.erb.tt +1 -1
  20. data/lib/generators/authentication/templates/erb/passwords/edit.html.erb.tt +1 -1
  21. data/lib/generators/authentication/templates/erb/session_mailer/signed_in.html.erb.tt +21 -0
  22. data/lib/generators/authentication/templates/erb/session_mailer/signed_in.text.erb.tt +17 -0
  23. data/lib/generators/authentication/templates/erb/sessions/index.html.erb.tt +34 -0
  24. data/lib/generators/authentication/templates/erb/sessions/new.html.erb.tt +1 -6
  25. data/lib/generators/authentication/templates/mailers/password_mailer.rb.tt +1 -5
  26. data/lib/generators/authentication/templates/mailers/session_mailer.rb.tt +6 -0
  27. data/lib/generators/authentication/templates/migrations/create_sessions_migration.rb.tt +11 -0
  28. data/lib/generators/authentication/templates/migrations/create_table_migration.rb.tt +12 -0
  29. data/lib/generators/authentication/templates/models/current.rb.tt +5 -1
  30. data/lib/generators/authentication/templates/models/model.rb.tt +2 -28
  31. data/lib/generators/authentication/templates/models/session.rb.tt +7 -0
  32. data/lib/generators/authentication/templates/test_unit/controllers/api/cancellations_controller_test.rb.tt +3 -3
  33. data/lib/generators/authentication/templates/test_unit/controllers/api/emails_controller_test.rb.tt +4 -9
  34. data/lib/generators/authentication/templates/test_unit/controllers/api/password_resets_controller_test.rb.tt +4 -11
  35. data/lib/generators/authentication/templates/test_unit/controllers/api/passwords_controller_test.rb.tt +4 -9
  36. data/lib/generators/authentication/templates/test_unit/controllers/api/sessions_controller_test.rb.tt +16 -6
  37. data/lib/generators/authentication/templates/test_unit/controllers/html/cancellations_controller_test.rb.tt +3 -3
  38. data/lib/generators/authentication/templates/test_unit/controllers/html/emails_controller_test.rb.tt +5 -10
  39. data/lib/generators/authentication/templates/test_unit/controllers/html/password_resets_controller_test.rb.tt +8 -8
  40. data/lib/generators/authentication/templates/test_unit/controllers/html/passwords_controller_test.rb.tt +5 -10
  41. data/lib/generators/authentication/templates/test_unit/controllers/html/registrations_controller_test.rb.tt +1 -3
  42. data/lib/generators/authentication/templates/test_unit/controllers/html/sessions_controller_test.rb.tt +14 -7
  43. data/lib/generators/authentication/templates/test_unit/fixtures.yml.tt +0 -1
  44. data/lib/generators/authentication/templates/test_unit/sessions.yml.tt +6 -0
  45. data/lib/generators/authentication/templates/test_unit/system/cancellations_test.rb.tt +2 -2
  46. data/lib/generators/authentication/templates/test_unit/system/emails_test.rb.tt +2 -2
  47. data/lib/generators/authentication/templates/test_unit/system/password_resets_test.rb.tt +2 -2
  48. data/lib/generators/authentication/templates/test_unit/system/passwords_test.rb.tt +2 -2
  49. data/lib/generators/authentication/templates/test_unit/system/sessions_test.rb.tt +8 -1
  50. metadata +10 -7
  51. data/lib/generators/authentication/templates/erb/email_mailer/changed.html.erb.tt +0 -11
  52. data/lib/generators/authentication/templates/erb/email_mailer/changed.text.erb.tt +0 -9
  53. data/lib/generators/authentication/templates/erb/password_mailer/changed.html.erb.tt +0 -7
  54. data/lib/generators/authentication/templates/erb/password_mailer/changed.text.erb.tt +0 -5
  55. data/lib/generators/authentication/templates/mailers/email_mailer.rb.tt +0 -6
@@ -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"]
@@ -24,6 +19,6 @@ class EmailsControllerTest < ActionDispatch::IntegrationTest
24
19
 
25
20
  def sign_in_as(<%= singular_table_name %>)
26
21
  post(sign_in_url, params: { email: <%= singular_table_name %>.email, password: "secret123" })
27
- [<%= singular_table_name %>, response.parsed_body["session_token"]]
28
- end
22
+ [<%= singular_table_name %>, response.headers["X-Session-Token"]]
23
+ end
29
24
  end
@@ -7,16 +7,9 @@ class PasswordResetsControllerTest < ActionDispatch::IntegrationTest
7
7
  @sid_exp = @<%= singular_table_name %>.signed_id(purpose: :password_reset, expires_in: 0.minutes)
8
8
  end
9
9
 
10
- test "should get edit" do
11
- get edit_password_resets_url(token: @sid)
12
-
13
- assert_response :not_found
14
- assert_equal "Open this link in your device", response.parsed_body["error"]
15
- end
16
-
17
10
  test "should send a password reset email" do
18
11
  assert_enqueued_email_with PasswordMailer, :reset, args: { <%= singular_table_name %>: @<%= singular_table_name %> } do
19
- post password_resets_url, params: { email: @<%= singular_table_name %>.email }
12
+ post password_reset_url, params: { email: @<%= singular_table_name %>.email }
20
13
  end
21
14
 
22
15
  assert_response :no_content
@@ -24,7 +17,7 @@ class PasswordResetsControllerTest < ActionDispatch::IntegrationTest
24
17
 
25
18
  test "should not send a password reset email to a nonexistent email" do
26
19
  assert_no_enqueued_emails do
27
- post password_resets_url, params: { email: "invalid_email@hey.com" }
20
+ post password_reset_url, params: { email: "invalid_email@hey.com" }
28
21
  end
29
22
 
30
23
  assert_response :not_found
@@ -32,12 +25,12 @@ class PasswordResetsControllerTest < ActionDispatch::IntegrationTest
32
25
  end
33
26
 
34
27
  test "should update password" do
35
- patch password_resets_url, params: { token: @sid, password: "new_password", password_confirmation: "new_password" }
28
+ patch password_reset_url, params: { token: @sid, password: "new_password", password_confirmation: "new_password" }
36
29
  assert_response :success
37
30
  end
38
31
 
39
32
  test "should not update password with expired token" do
40
- patch password_resets_url, params: { token: @sid_exp, password: "new_password", password_confirmation: "new_password" }
33
+ patch password_reset_url, params: { token: @sid_exp, password: "new_password", password_confirmation: "new_password" }
41
34
 
42
35
  assert_response :bad_request
43
36
  assert_equal "Your token has expired, please request a new one", response.parsed_body["error"]
@@ -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"]
@@ -24,6 +19,6 @@ class PasswordsControllerTest < ActionDispatch::IntegrationTest
24
19
 
25
20
  def sign_in_as(<%= singular_table_name %>)
26
21
  post(sign_in_url, params: { email: <%= singular_table_name %>.email, password: "secret123" })
27
- [<%= singular_table_name %>, response.parsed_body["session_token"]]
28
- end
22
+ [<%= singular_table_name %>, response.headers["X-Session-Token"]]
23
+ end
29
24
  end
@@ -2,12 +2,24 @@ require "test_helper"
2
2
 
3
3
  class SessionsControllerTest < ActionDispatch::IntegrationTest
4
4
  setup do
5
- @<%= singular_table_name %> = <%= table_name %>(:lazaro_nixon)
5
+ @<%= singular_table_name %>, @token = sign_in_as(<%= table_name %>(:lazaro_nixon))
6
+ end
7
+
8
+ test "should get index" do
9
+ get sessions_url, headers: { "Authorization" => "Bearer #{@token}" }
10
+ assert_response :success
11
+ end
12
+
13
+ test "should show session" do
14
+ get session_url(@<%= singular_table_name %>.sessions.last), headers: { "Authorization" => "Bearer #{@token}" }
15
+ assert_response :success
6
16
  end
7
17
 
8
18
  test "should sign in" do
9
19
  post sign_in_url, params: { email: @<%= singular_table_name %>.email, password: "secret123" }
10
- assert_response :success
20
+
21
+ assert_enqueued_email_with SessionMailer, :signed_in, args: { session: @<%= singular_table_name %>.sessions.last }
22
+ assert_response :created
11
23
  end
12
24
 
13
25
  test "should not sign in with wrong credentials" do
@@ -16,14 +28,12 @@ class SessionsControllerTest < ActionDispatch::IntegrationTest
16
28
  end
17
29
 
18
30
  test "should sign out" do
19
- <%= singular_table_name %>, token = sign_in_as(@<%= singular_table_name %>)
20
-
21
- delete sign_out_url, headers: { "Authorization" => "Bearer #{token}" }
31
+ delete session_url(@<%= singular_table_name %>.sessions.last), headers: { "Authorization" => "Bearer #{@token}" }
22
32
  assert_response :no_content
23
33
  end
24
34
 
25
35
  def sign_in_as(<%= singular_table_name %>)
26
36
  post(sign_in_url, params: { email: <%= singular_table_name %>.email, password: "secret123" })
27
- [<%= singular_table_name %>, response.parsed_body["session_token"]]
37
+ [<%= singular_table_name %>, response.headers["X-Session-Token"]]
28
38
  end
29
39
  end
@@ -6,19 +6,19 @@ class CancellationsControllerTest < ActionDispatch::IntegrationTest
6
6
  end
7
7
 
8
8
  test "should get new" do
9
- get new_cancellations_url
9
+ get new_cancellation_url
10
10
  assert_response :success
11
11
  end
12
12
 
13
13
  test "should create cancellation" do
14
14
  assert_difference("<%= class_name %>.count", -1) do
15
- post cancellations_url
15
+ post cancellation_url
16
16
  end
17
17
 
18
18
  assert_redirected_to sign_in_url
19
19
  end
20
20
 
21
21
  def sign_in_as(<%= singular_table_name %>)
22
- post(sign_in_url, params: { email: <%= singular_table_name %>.email, password: "secret123" }); user
22
+ post(sign_in_url, params: { email: <%= singular_table_name %>.email, password: "secret123" }); <%= singular_table_name %>
23
23
  end
24
24
  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
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 }
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,22 @@ 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
33
+ assert_redirected_to new_password_reset_url
34
34
  assert_equal "Sorry, we didn't recognize that email address", flash[:alert]
35
35
  end
36
36
 
37
37
  test "should update password" do
38
- patch password_resets_url, params: { token: @sid, <%= singular_table_name %>: { password: "new_password", password_confirmation: "new_password" } }
38
+ patch password_reset_url, params: { token: @sid, <%= singular_table_name %>: { password: "new_password", password_confirmation: "new_password" } }
39
39
  assert_redirected_to sign_in_path
40
40
  end
41
41
 
42
42
  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" }
43
+ patch password_reset_url, params: { token: @sid_exp, password: "new_password", password_confirmation: "new_password" }
44
44
 
45
- assert_redirected_to new_password_resets_path
45
+ assert_redirected_to new_password_reset_path
46
46
  assert_equal "Your token has expired, please request a new one", flash[:alert]
47
47
  end
48
48
  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,7 @@ 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
17
15
  end
18
16
  end
@@ -5,6 +5,13 @@ class SessionsControllerTest < ActionDispatch::IntegrationTest
5
5
  @<%= singular_table_name %> = <%= table_name %>(:lazaro_nixon)
6
6
  end
7
7
 
8
+ test "should get index" do
9
+ sign_in_as @<%= singular_table_name %>
10
+
11
+ get sessions_url
12
+ assert_response :success
13
+ end
14
+
8
15
  test "should get new" do
9
16
  get sign_in_url
10
17
  assert_response :success
@@ -12,6 +19,8 @@ class SessionsControllerTest < ActionDispatch::IntegrationTest
12
19
 
13
20
  test "should sign in" do
14
21
  post sign_in_url, params: { email: @<%= singular_table_name %>.email, password: "secret123" }
22
+ assert_enqueued_email_with SessionMailer, :signed_in, args: { session: @<%= singular_table_name %>.sessions.last }
23
+
15
24
  assert_redirected_to root_url
16
25
 
17
26
  get root_url
@@ -21,25 +30,23 @@ class SessionsControllerTest < ActionDispatch::IntegrationTest
21
30
  test "should not sign in with wrong credentials" do
22
31
  post sign_in_url, params: { email: @<%= singular_table_name %>.email, password: "wrong_password" }
23
32
  assert_redirected_to sign_in_url(email_hint: @<%= singular_table_name %>.email)
24
- assert_equal "Invalid email or password", flash[:alert]
33
+ assert_equal "That email or password is incorrect", flash[:alert]
25
34
 
26
35
  get root_url
27
36
  assert_redirected_to sign_in_path
28
- assert_equal "You need to sign in or sign up before continuing", flash[:alert]
29
37
  end
30
38
 
31
39
  test "should sign out" do
32
40
  sign_in_as @<%= singular_table_name %>
33
41
 
34
- delete sign_out_url
35
- assert_redirected_to sign_in_path
42
+ delete session_url(@<%= singular_table_name %>.sessions.last)
43
+ assert_redirected_to sessions_path
36
44
 
37
- get root_path
45
+ follow_redirect!
38
46
  assert_redirected_to sign_in_path
39
- assert_equal "You need to sign in or sign up before continuing", flash[:alert]
40
47
  end
41
48
 
42
49
  def sign_in_as(<%= singular_table_name %>)
43
- 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 %>
44
51
  end
45
52
  end
@@ -3,4 +3,3 @@
3
3
  lazaro_nixon:
4
4
  email: lazaronixon@hotmail.com
5
5
  password_digest: <%%= BCrypt::Password.create("secret123") %>
6
- session_token: <%%= SecureRandom.base58(24) %>
@@ -0,0 +1,6 @@
1
+ # Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
2
+
3
+ lazaro_nixon_ios:
4
+ <%= singular_table_name %>: lazaro_nixon
5
+ user_agent: Device iOS
6
+ ip_address: 127.0.0.1
@@ -9,7 +9,7 @@ class CancellationsTest < ApplicationSystemTestCase
9
9
  click_on "Cancel my account & delete my data"
10
10
  click_on "OK, close my account"
11
11
 
12
- assert_text "Bye! Your account has been successfully cancelled"
12
+ assert_text "Your account is closed"
13
13
  end
14
14
 
15
15
  def sign_in_as(<%= singular_table_name %>)
@@ -19,5 +19,5 @@ class CancellationsTest < ApplicationSystemTestCase
19
19
  click_on "Sign in"
20
20
 
21
21
  return <%= singular_table_name %>
22
- end
22
+ end
23
23
  end
@@ -12,7 +12,7 @@ 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
16
  end
17
17
 
18
18
  def sign_in_as(<%= singular_table_name %>)
@@ -22,5 +22,5 @@ class EmailsTest < ApplicationSystemTestCase
22
22
  click_on "Sign in"
23
23
 
24
24
  return <%= singular_table_name %>
25
- end
25
+ end
26
26
  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
@@ -5,6 +5,13 @@ class SessionsTest < ApplicationSystemTestCase
5
5
  @<%= singular_table_name %> = <%= table_name %>(:lazaro_nixon)
6
6
  end
7
7
 
8
+ test "visiting the index" do
9
+ sign_in_as @<%= singular_table_name %>
10
+
11
+ click_on "Manage Sessions"
12
+ assert_selector "h1", text: "Sessions"
13
+ end
14
+
8
15
  test "signing in" do
9
16
  visit sign_in_url
10
17
  fill_in "Email", with: @<%= singular_table_name %>.email
@@ -18,7 +25,7 @@ class SessionsTest < ApplicationSystemTestCase
18
25
  sign_in_as @<%= singular_table_name %>
19
26
 
20
27
  click_on "Log out"
21
- assert_text "Signed out successfully"
28
+ assert_selector "h1", text: "Sign in"
22
29
  end
23
30
 
24
31
  def sign_in_as(<%= singular_table_name %>)
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: 1.0.2
4
+ version: 2.1.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-22 00:00:00.000000000 Z
11
+ date: 2022-02-23 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email:
@@ -44,22 +44,24 @@ files:
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
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
47
  - 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
48
  - lib/generators/authentication/templates/erb/password_mailer/reset.html.erb.tt
53
49
  - lib/generators/authentication/templates/erb/password_mailer/reset.text.erb.tt
54
50
  - lib/generators/authentication/templates/erb/password_resets/edit.html.erb.tt
55
51
  - lib/generators/authentication/templates/erb/password_resets/new.html.erb.tt
56
52
  - lib/generators/authentication/templates/erb/passwords/edit.html.erb.tt
57
53
  - lib/generators/authentication/templates/erb/registrations/new.html.erb.tt
54
+ - lib/generators/authentication/templates/erb/session_mailer/signed_in.html.erb.tt
55
+ - lib/generators/authentication/templates/erb/session_mailer/signed_in.text.erb.tt
56
+ - lib/generators/authentication/templates/erb/sessions/index.html.erb.tt
58
57
  - lib/generators/authentication/templates/erb/sessions/new.html.erb.tt
59
- - lib/generators/authentication/templates/mailers/email_mailer.rb.tt
60
58
  - lib/generators/authentication/templates/mailers/password_mailer.rb.tt
59
+ - lib/generators/authentication/templates/mailers/session_mailer.rb.tt
60
+ - lib/generators/authentication/templates/migrations/create_sessions_migration.rb.tt
61
+ - lib/generators/authentication/templates/migrations/create_table_migration.rb.tt
61
62
  - lib/generators/authentication/templates/models/current.rb.tt
62
63
  - lib/generators/authentication/templates/models/model.rb.tt
64
+ - lib/generators/authentication/templates/models/session.rb.tt
63
65
  - lib/generators/authentication/templates/test_unit/controllers/api/cancellations_controller_test.rb.tt
64
66
  - lib/generators/authentication/templates/test_unit/controllers/api/emails_controller_test.rb.tt
65
67
  - lib/generators/authentication/templates/test_unit/controllers/api/password_resets_controller_test.rb.tt
@@ -73,6 +75,7 @@ files:
73
75
  - lib/generators/authentication/templates/test_unit/controllers/html/registrations_controller_test.rb.tt
74
76
  - lib/generators/authentication/templates/test_unit/controllers/html/sessions_controller_test.rb.tt
75
77
  - lib/generators/authentication/templates/test_unit/fixtures.yml.tt
78
+ - lib/generators/authentication/templates/test_unit/sessions.yml.tt
76
79
  - lib/generators/authentication/templates/test_unit/system/cancellations_test.rb.tt
77
80
  - lib/generators/authentication/templates/test_unit/system/emails_test.rb.tt
78
81
  - lib/generators/authentication/templates/test_unit/system/password_resets_test.rb.tt
@@ -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