authentication-zero 0.0.11 → 0.0.15

Sign up to get free protection for your applications and to get access to all the features.
Files changed (30) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/README.md +31 -2
  4. data/lib/authentication_zero/version.rb +1 -1
  5. data/lib/generators/authentication/authentication_generator.rb +9 -11
  6. data/lib/generators/authentication/templates/controllers/api/cancellations_controller.rb.tt +1 -1
  7. data/lib/generators/authentication/templates/controllers/api/emails_controller.rb.tt +22 -0
  8. data/lib/generators/authentication/templates/controllers/api/password_resets_controller.rb.tt +4 -5
  9. data/lib/generators/authentication/templates/controllers/api/passwords_controller.rb.tt +3 -3
  10. data/lib/generators/authentication/templates/controllers/api/registrations_controller.rb.tt +1 -1
  11. data/lib/generators/authentication/templates/controllers/html/cancellations_controller.rb.tt +1 -1
  12. data/lib/generators/authentication/templates/controllers/html/emails_controller.rb.tt +25 -0
  13. data/lib/generators/authentication/templates/controllers/html/password_resets_controller.rb.tt +5 -6
  14. data/lib/generators/authentication/templates/controllers/html/passwords_controller.rb.tt +3 -4
  15. data/lib/generators/authentication/templates/mailers/email_mailer.rb.tt +6 -0
  16. data/lib/generators/authentication/templates/mailers/password_mailer.rb.tt +4 -0
  17. data/lib/generators/authentication/templates/models/resource.rb.tt +17 -3
  18. data/lib/generators/authentication/templates/views/cancellations/new.html.erb.tt +1 -1
  19. data/lib/generators/authentication/templates/views/email_mailer/changed.html.erb.tt +11 -0
  20. data/lib/generators/authentication/templates/views/email_mailer/changed.text.erb.tt +9 -0
  21. data/lib/generators/authentication/templates/views/emails/edit.html.erb.tt +37 -0
  22. data/lib/generators/authentication/templates/views/password_mailer/changed.html.erb.tt +7 -0
  23. data/lib/generators/authentication/templates/views/password_mailer/changed.text.erb.tt +5 -0
  24. data/lib/generators/authentication/templates/views/password_mailer/reset.html.erb.tt +1 -1
  25. data/lib/generators/authentication/templates/views/password_mailer/reset.text.erb.tt +1 -1
  26. data/lib/generators/authentication/templates/views/password_resets/edit.html.erb.tt +2 -2
  27. data/lib/generators/authentication/templates/views/password_resets/new.html.erb.tt +1 -1
  28. data/lib/generators/authentication/templates/views/passwords/edit.html.erb.tt +1 -1
  29. data/lib/generators/authentication/templates/views/sessions/new.html.erb.tt +1 -1
  30. metadata +10 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0ea1c631f09f3da8a3b5e183d431e5596875bd04044b0a6e74a44943d7eabb8d
4
- data.tar.gz: 8242c5411752b806bca65bf8b3ac0d457231b830381b5d0369e6ea2daa2374f0
3
+ metadata.gz: 39cf93fc2be059b756c15125cfd0d4e35e0a8f96a803fbfcfb3aa31f64b2a704
4
+ data.tar.gz: 728fdd4a2af75e207db825c581e8fb1856be8d55b4fbfe6ac19aaa8e373b8557
5
5
  SHA512:
6
- metadata.gz: 4f73c08b89896448ceb9ce7b19df4d97a6c7ec20bfbd977c2b07b10ef20535a45a94015ccee0e13c23351388e69d0b10598a9c2ed4678858147753fdf78631d8
7
- data.tar.gz: 02d3dfd0571bb4d8f20a91eeae99f5d430f747c8651751ad4eecb566b214488535d029e746c63ea6c5a76566fc4e115c88d2c1f8a4b3801d02d0d0edc896f1ea
6
+ metadata.gz: ca7dc09acf69d59ada1e204fb77076731212afadddf77337eccc22466307917eed2e5cc1f11b92eee6bcd8722970a021c4ca48664f92714acd9f4c7579978db0
7
+ data.tar.gz: fe83d4649cf6c24fbbadecfee09dfdd1d245fb689da031eb187f061df26a9d6704cee1db904aa6c3c7c17763c51665637dd58f20515c08e93a88542c01879991
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- authentication-zero (0.0.11)
4
+ authentication-zero (0.0.15)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -2,6 +2,31 @@
2
2
 
3
3
  The purpose of authentication zero is to generate a pre-built authentication system into a rails application (web or api-only) that follows both security and rails best practices. By generating code into the user's application instead of using a library, the user has complete freedom to modify the authentication system so it works best with their app.
4
4
 
5
+ ## Features
6
+
7
+ - Sign up
8
+ - Email and password validations
9
+ - Reset the user password and send reset instructions
10
+ - Authentication by cookie (html)
11
+ - Authentication by token (api)
12
+ - Remember me (html)
13
+ - Send e-mail when email is changed
14
+ - Send e-mail when password is changed
15
+ - Cancel my account
16
+ - Log out
17
+
18
+ ## Security and best practices
19
+
20
+ - [Current attributes](https://api.rubyonrails.org/classes/ActiveSupport/CurrentAttributes.html): Abstract super class that provides a thread-isolated attributes singleton, which resets automatically before and after each request.
21
+ - [has_secure_password](https://api.rubyonrails.org/classes/ActiveModel/SecurePassword/ClassMethods.html#method-i-has_secure_password): Adds methods to set and authenticate against a BCrypt password.
22
+ - [has_secure_token](https://api.rubyonrails.org/classes/ActiveRecord/SecureToken/ClassMethods.html#method-i-has_secure_token): Adds methods to generate unique tokens.
23
+ - [authenticate_with_http_token](https://api.rubyonrails.org/classes/ActionController/HttpAuthentication/Token.html): Compare the tokens in a time-constant manner, to mitigate timing attacks.
24
+ - [signed_id](https://api.rubyonrails.org/classes/ActiveRecord/SignedId.html): Returns a signed id that is tamper proof, so it's safe to send in an email or otherwise share with the outside world.
25
+ - [Http only cookies](https://api.rubyonrails.org/classes/ActionDispatch/Cookies.html): A cookie with the httponly attribute is inaccessible to the JavaScript, this precaution helps mitigate cross-site scripting (XSS) attacks.
26
+ - [Log filtering](https://guides.rubyonrails.org/action_controller_overview.html#log-filtering): Parameters 'token' and 'password' are marked [FILTERED] in the log.
27
+ - [Callbacks](https://api.rubyonrails.org/classes/ActiveRecord/Callbacks.html): We use callbacks to send emails before changing an email or password.
28
+ - [ActionMailer](https://api.rubyonrails.org/classes/ActionMailer/Base.html): Action Mailer allows you to send email from your application using a mailer model and views.
29
+
5
30
  ## Installation
6
31
 
7
32
  Add this lines to your application's Gemfile:
@@ -31,11 +56,15 @@ Add these lines to your `app/views/home/index.html.erb`:
31
56
  <p>Signed as <%= Current.user.email %></p>
32
57
 
33
58
  <div>
34
- <%= link_to "Change password", password_edit_path %>
59
+ <%= link_to "Change email", edit_emails_path %>
60
+ </div>
61
+
62
+ <div>
63
+ <%= link_to "Change password", edit_passwords_path %>
35
64
  </div>
36
65
 
37
66
  <div>
38
- <%= link_to "Cancel my account & delete my data", cancellation_new_path %>
67
+ <%= link_to "Cancel my account & delete my data", new_cancellations_path %>
39
68
  </div>
40
69
 
41
70
  <%= button_to "Log out", sign_out_path, method: :delete %>
@@ -1,3 +1,3 @@
1
1
  module AuthenticationZero
2
- VERSION = "0.0.11"
2
+ VERSION = "0.0.15"
3
3
  end
@@ -16,11 +16,13 @@ class AuthenticationGenerator < Rails::Generators::NamedBase
16
16
  end
17
17
 
18
18
  def create_mailers
19
+ template "mailers/email_mailer.rb", "app/mailers/email_mailer.rb"
19
20
  template "mailers/password_mailer.rb", "app/mailers/password_mailer.rb"
20
21
  end
21
22
 
22
23
  def create_views
23
24
  if options.api
25
+ directory "views/email_mailer", "app/views/email_mailer"
24
26
  directory "views/password_mailer", "app/views/password_mailer"
25
27
  else
26
28
  directory "views", "app/views"
@@ -37,19 +39,15 @@ class AuthenticationGenerator < Rails::Generators::NamedBase
37
39
  end
38
40
 
39
41
  def add_routes
40
- route "get 'sign_up', to: 'registrations#new'" unless options.api?
42
+ route "resource :password_resets, only: [:new, :edit, :create, :update]"
43
+ route "resource :cancellations, only: [:new, :create]"
44
+ route "resource :passwords, only: [:edit, :update]"
45
+ route "resource :emails, only: [:edit, :update]"
46
+ route "delete 'sign_out', to: 'sessions#destroy'"
41
47
  route "post 'sign_up', to: 'registrations#create'"
42
- route "get 'sign_in', to: 'sessions#new'" unless options.api?
48
+ route "get 'sign_up', to: 'registrations#new'" unless options.api?
43
49
  route "post 'sign_in', to: 'sessions#create'"
44
- route "get 'password/edit', to: 'passwords#edit'" unless options.api?
45
- route "patch 'password', to: 'passwords#update'"
46
- route "get 'cancellation/new', to: 'cancellations#new'" unless options.api?
47
- route "post 'cancellation', to: 'cancellations#destroy'"
48
- route "get 'password_reset/new', to: 'password_resets#new'" unless options.api?
49
- route "post 'password_reset', to: 'password_resets#create'"
50
- route "get 'password_reset/edit', to: 'password_resets#edit'"
51
- route "patch 'password_reset', to: 'password_resets#update'"
52
- route "delete 'sign_out', to: 'sessions#destroy'"
50
+ route "get 'sign_in', to: 'sessions#new'" unless options.api?
53
51
  end
54
52
 
55
53
  def add_application_controller_methods
@@ -1,5 +1,5 @@
1
1
  class CancellationsController < ApplicationController
2
- def destroy
2
+ def create
3
3
  Current.<%= singular_table_name %>.destroy
4
4
  end
5
5
  end
@@ -0,0 +1,22 @@
1
+ class EmailsController < ApplicationController
2
+ before_action :set_<%= singular_table_name %>
3
+
4
+ def update
5
+ if !@<%= singular_table_name %>.authenticate(params[:current_password])
6
+ render json: { error: "The current password you entered is incorrect" }, status: :bad_request
7
+ elsif @<%= singular_table_name %>.update(<%= "#{singular_table_name}_params" %>)
8
+ render json: @<%= singular_table_name %>
9
+ else
10
+ render json: @<%= singular_table_name %>.errors, status: :unprocessable_entity
11
+ end
12
+ end
13
+
14
+ private
15
+ def set_<%= singular_table_name %>
16
+ @<%= singular_table_name %> = Current.<%= singular_table_name %>
17
+ end
18
+
19
+ def <%= "#{singular_table_name}_params" %>
20
+ params.permit(:email)
21
+ end
22
+ end
@@ -1,6 +1,5 @@
1
1
  class PasswordResetsController < ApplicationController
2
2
  skip_before_action :authenticate
3
-
4
3
  before_action :set_<%= singular_table_name %>, only: %i[ edit update ]
5
4
 
6
5
  def edit
@@ -16,7 +15,7 @@ class PasswordResetsController < ApplicationController
16
15
  end
17
16
 
18
17
  def update
19
- if @<%= singular_table_name %>.update(password_params)
18
+ if @<%= singular_table_name %>.update(<%= "#{singular_table_name}_params" %>)
20
19
  render json: @<%= singular_table_name %>
21
20
  else
22
21
  render json: @<%= singular_table_name %>.errors, status: :unprocessable_entity
@@ -25,12 +24,12 @@ class PasswordResetsController < ApplicationController
25
24
 
26
25
  private
27
26
  def set_<%= singular_table_name %>
28
- @<%= singular_table_name %> = <%= class_name %>.find_signed!(params[:sid], purpose: "password_reset")
27
+ @<%= singular_table_name %> = <%= class_name %>.find_signed!(params[:token], purpose: "password_reset")
29
28
  rescue ActiveSupport::MessageVerifier::InvalidSignature
30
29
  render json: { error: "Your token has expired, please request a new one" }, status: :bad_request
31
30
  end
32
31
 
33
- def password_params
34
- params.require(:<%= singular_table_name %>).permit(:password, :password_confirmation)
32
+ def <%= "#{singular_table_name}_params" %>
33
+ params.permit(:password, :password_confirmation)
35
34
  end
36
35
  end
@@ -4,7 +4,7 @@ class PasswordsController < ApplicationController
4
4
  def update
5
5
  if !@<%= singular_table_name %>.authenticate(params[:current_password])
6
6
  render json: { error: "The current password you entered is incorrect" }, status: :bad_request
7
- elsif @<%= singular_table_name %>.update(password_params)
7
+ elsif @<%= singular_table_name %>.update(<%= "#{singular_table_name}_params" %>)
8
8
  render json: @<%= singular_table_name %>
9
9
  else
10
10
  render json: @<%= singular_table_name %>.errors, status: :unprocessable_entity
@@ -16,7 +16,7 @@ class PasswordsController < ApplicationController
16
16
  @<%= singular_table_name %> = Current.<%= singular_table_name %>
17
17
  end
18
18
 
19
- def password_params
20
- params.require(:<%= singular_table_name %>).permit(:password, :password_confirmation)
19
+ def <%= "#{singular_table_name}_params" %>
20
+ params.permit(:password, :password_confirmation)
21
21
  end
22
22
  end
@@ -13,6 +13,6 @@ class RegistrationsController < ApplicationController
13
13
 
14
14
  private
15
15
  def <%= "#{singular_table_name}_params" %>
16
- params.require(:<%= singular_table_name %>).permit(:email, :password, :password_confirmation)
16
+ params.permit(:email, :password, :password_confirmation)
17
17
  end
18
18
  end
@@ -2,7 +2,7 @@ class CancellationsController < ApplicationController
2
2
  def new
3
3
  end
4
4
 
5
- def destroy
5
+ def create
6
6
  Current.<%= singular_table_name %>.destroy
7
7
  redirect_to sign_in_path, notice: "Bye! Your account has been successfully cancelled"
8
8
  end
@@ -0,0 +1,25 @@
1
+ class EmailsController < ApplicationController
2
+ before_action :set_<%= singular_table_name %>
3
+
4
+ def edit
5
+ end
6
+
7
+ def update
8
+ if !@<%= singular_table_name %>.authenticate(params[:current_password])
9
+ redirect_to edit_emails_path, alert: "The current password you entered is incorrect"
10
+ elsif @<%= singular_table_name %>.update(<%= "#{singular_table_name}_params" %>)
11
+ redirect_to root_path, notice: "Your email has been changed successfully"
12
+ else
13
+ render :edit, status: :unprocessable_entity
14
+ end
15
+ end
16
+
17
+ private
18
+ def set_<%= singular_table_name %>
19
+ @<%= singular_table_name %> = Current.<%= singular_table_name %>
20
+ end
21
+
22
+ def <%= "#{singular_table_name}_params" %>
23
+ params.require(:<%= singular_table_name %>).permit(:email)
24
+ end
25
+ end
@@ -1,6 +1,5 @@
1
1
  class PasswordResetsController < ApplicationController
2
2
  skip_before_action :authenticate
3
-
4
3
  before_action :set_<%= singular_table_name %>, only: %i[ edit update ]
5
4
 
6
5
  def new
@@ -14,12 +13,12 @@ class PasswordResetsController < ApplicationController
14
13
  PasswordMailer.with(<%= singular_table_name %>: @<%= singular_table_name %>).reset.deliver_later
15
14
  redirect_to sign_in_path, notice: "You will receive an email with instructions on how to reset your password in a few minutes"
16
15
  else
17
- redirect_to password_reset_new_path, alert: "The email address doesn't exist in our database"
16
+ redirect_to new_password_resets_path, alert: "The email address doesn't exist in our database"
18
17
  end
19
18
  end
20
19
 
21
20
  def update
22
- if @<%= singular_table_name %>.update(password_params)
21
+ if @<%= singular_table_name %>.update(<%= "#{singular_table_name}_params" %>)
23
22
  redirect_to sign_in_path, notice: "Your password was reset successfully. Please sign in"
24
23
  else
25
24
  render :edit, status: :unprocessable_entity
@@ -28,12 +27,12 @@ class PasswordResetsController < ApplicationController
28
27
 
29
28
  private
30
29
  def set_<%= singular_table_name %>
31
- @<%= singular_table_name %> = <%= class_name %>.find_signed!(params[:sid], purpose: "password_reset")
30
+ @<%= singular_table_name %> = <%= class_name %>.find_signed!(params[:token], purpose: "password_reset")
32
31
  rescue ActiveSupport::MessageVerifier::InvalidSignature
33
- redirect_to password_reset_new_path, alert: "Your token has expired, please request a new one"
32
+ redirect_to new_password_resets_path, alert: "Your token has expired, please request a new one"
34
33
  end
35
34
 
36
- def password_params
35
+ def <%= "#{singular_table_name}_params" %>
37
36
  params.require(:<%= singular_table_name %>).permit(:password, :password_confirmation)
38
37
  end
39
38
  end
@@ -2,13 +2,12 @@ class PasswordsController < ApplicationController
2
2
  before_action :set_<%= singular_table_name %>
3
3
 
4
4
  def edit
5
- @<%= singular_table_name %> = Current.<%= singular_table_name %>
6
5
  end
7
6
 
8
7
  def update
9
8
  if !@<%= singular_table_name %>.authenticate(params[:current_password])
10
- redirect_to password_edit_path, alert: "The current password you entered is incorrect"
11
- elsif @<%= singular_table_name %>.update(password_params)
9
+ redirect_to edit_passwords_path, alert: "The current password you entered is incorrect"
10
+ elsif @<%= singular_table_name %>.update(<%= "#{singular_table_name}_params" %>)
12
11
  redirect_to root_path, notice: "Your password has been changed successfully"
13
12
  else
14
13
  render :edit, status: :unprocessable_entity
@@ -20,7 +19,7 @@ class PasswordsController < ApplicationController
20
19
  @<%= singular_table_name %> = Current.<%= singular_table_name %>
21
20
  end
22
21
 
23
- def password_params
22
+ def <%= "#{singular_table_name}_params" %>
24
23
  params.require(:<%= singular_table_name %>).permit(:password, :password_confirmation)
25
24
  end
26
25
  end
@@ -0,0 +1,6 @@
1
+ class EmailMailer < ApplicationMailer
2
+ def changed
3
+ @previous_email, @current_email = params[:change]
4
+ mail to: @previous_email
5
+ end
6
+ end
@@ -1,4 +1,8 @@
1
1
  class PasswordMailer < ApplicationMailer
2
+ def changed
3
+ mail to: params[:<%= singular_table_name %>].email
4
+ end
5
+
2
6
  def reset
3
7
  @signed_id = params[:<%= singular_table_name %>].signed_id(purpose: "password_reset", expires_in: 20.minutes)
4
8
  mail to: params[:<%= singular_table_name %>].email
@@ -6,9 +6,23 @@ class <%= class_name %> < ApplicationRecord
6
6
  validates :email, format: { with: /\A[^@\s]+@[^@\s]+\z/ }
7
7
  validates_length_of :password, minimum: 8, allow_blank: true
8
8
 
9
- before_validation { self.email = email.downcase.strip }
9
+ before_validation do
10
+ self.email = email.downcase.strip
11
+ end
10
12
 
11
- def as_json(options)
13
+ after_update_commit do
14
+ if self.email_previously_changed?
15
+ EmailMailer.with(change: self.email_previous_change).changed.deliver_later
16
+ end
17
+ end
18
+
19
+ after_update_commit do
20
+ if self.password_digest_previously_changed?
21
+ PasswordMailer.with(<%= singular_table_name %>: self).changed.deliver_later
22
+ end
23
+ end
24
+
25
+ def as_json(options = {})
12
26
  super(options.merge(except: [:password_digest, :session_token]))
13
- end
27
+ end
14
28
  end
@@ -7,5 +7,5 @@
7
7
  <br>
8
8
 
9
9
  <div>
10
- <%%= button_to "OK, close my account", cancellation_path %>
10
+ <%%= button_to "OK, close my account", cancellations_path %>
11
11
  </div>
@@ -0,0 +1,11 @@
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>
@@ -0,0 +1,9 @@
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.
@@ -0,0 +1,37 @@
1
+ <p style="color: red"><%%= alert %></p>
2
+
3
+ <h1>Change your email</h1>
4
+
5
+ <%%= form_with(model: @<%= model_resource_name %>, url: emails_path) do |form| %>
6
+ <%% if @<%= singular_table_name %>.errors.any? %>
7
+ <div style="color: red">
8
+ <h2><%%= pluralize(@<%= singular_table_name %>.errors.count, "error") %> prohibited this <%= singular_table_name %> from being saved:</h2>
9
+
10
+ <ul>
11
+ <%% @<%= singular_table_name %>.errors.each do |error| %>
12
+ <li><%%= error.full_message %></li>
13
+ <%% end %>
14
+ </ul>
15
+ </div>
16
+ <%% end %>
17
+
18
+ <div>
19
+ <%%= label_tag :current_password, nil, style: "display: block" %>
20
+ <%%= password_field_tag :current_password, nil, autofocus: true, autocomplete: "current-password" %>
21
+ </div>
22
+
23
+ <div>
24
+ <%%= form.label :email, "New email", style: "display: block" %>
25
+ <%%= form.email_field :email %>
26
+ </div>
27
+
28
+ <div>
29
+ <%%= form.submit "Save changes" %>
30
+ </div>
31
+ <%% end %>
32
+
33
+ <br>
34
+
35
+ <div>
36
+ <%%= link_to "Back", root_path %>
37
+ </div>
@@ -0,0 +1,7 @@
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>
@@ -0,0 +1,5 @@
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.
@@ -2,7 +2,7 @@
2
2
 
3
3
  <p>Can't remember your password for <strong><%%= params[:<%= singular_table_name %>].email %></strong>? That's OK, it happens. Just hit the link below to set a new one.</p>
4
4
 
5
- <p><%%= link_to "Reset my password", password_reset_edit_url(sid: @signed_id) %></p>
5
+ <p><%%= link_to "Reset my password", edit_password_resets_url(token: @signed_id) %></p>
6
6
 
7
7
  <p>If you did not request a password reset you can safely ignore this email, it expires in 20 minutes. Only someone with access to this email account can reset your password.</p>
8
8
 
@@ -2,7 +2,7 @@ Hey there,
2
2
 
3
3
  Can't remember your password for <%%= params[:<%= singular_table_name %>].email %>? That's OK, it happens. Just hit the link below to set a new one.
4
4
 
5
- [Reset my password]<%%= password_reset_edit_url(sid: @signed_id) %>
5
+ [Reset my password]<%%= edit_password_resets_url(token: @signed_id) %>
6
6
 
7
7
  If you did not request a password reset you can safely ignore this email, it expires in 20 minutes. Only someone with access to this email account can reset your password.
8
8
 
@@ -1,6 +1,6 @@
1
1
  <h1>Reset your password</h1>
2
2
 
3
- <%%= form_with(model: @<%= model_resource_name %>, url: password_reset_path) do |form| %>
3
+ <%%= form_with(model: @<%= model_resource_name %>, url: password_resets_path) do |form| %>
4
4
  <%% if @<%= singular_table_name %>.errors.any? %>
5
5
  <div style="color: red">
6
6
  <h2><%%= pluralize(@<%= singular_table_name %>.errors.count, "error") %> prohibited this <%= singular_table_name %> from being saved:</h2>
@@ -13,7 +13,7 @@
13
13
  </div>
14
14
  <%% end %>
15
15
 
16
- <%%= hidden_field_tag :sid, params[:sid] %>
16
+ <%%= hidden_field_tag :token, params[:token] %>
17
17
 
18
18
  <div>
19
19
  <%%= form.label :password, "New password", style: "display: block" %>
@@ -2,7 +2,7 @@
2
2
 
3
3
  <h1>Forgot your password?</h1>
4
4
 
5
- <%%= form_with(url: password_reset_path) do |form| %>
5
+ <%%= form_with(url: password_resets_path) do |form| %>
6
6
  <div>
7
7
  <%%= form.label :email, style: "display: block" %>
8
8
  <%%= form.email_field :email, autofocus: true, required: true %>
@@ -2,7 +2,7 @@
2
2
 
3
3
  <h1>Change your password</h1>
4
4
 
5
- <%%= form_with(model: @<%= model_resource_name %>, url: password_path) do |form| %>
5
+ <%%= form_with(model: @<%= model_resource_name %>, url: passwords_path) do |form| %>
6
6
  <%% if @<%= singular_table_name %>.errors.any? %>
7
7
  <div style="color: red">
8
8
  <h2><%%= pluralize(@<%= singular_table_name %>.errors.count, "error") %> prohibited this <%= singular_table_name %> from being saved:</h2>
@@ -28,5 +28,5 @@
28
28
 
29
29
  <div>
30
30
  <%%= link_to "Sign up", sign_up_path %> |
31
- <%%= link_to "Forgot your password?", password_reset_new_path %>
31
+ <%%= link_to "Forgot your password?", new_password_resets_path %>
32
32
  </div>
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: 0.0.11
4
+ version: 0.0.15
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-16 00:00:00.000000000 Z
11
+ date: 2022-02-17 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email:
@@ -32,20 +32,28 @@ files:
32
32
  - lib/generators/authentication/USAGE
33
33
  - lib/generators/authentication/authentication_generator.rb
34
34
  - lib/generators/authentication/templates/controllers/api/cancellations_controller.rb.tt
35
+ - lib/generators/authentication/templates/controllers/api/emails_controller.rb.tt
35
36
  - lib/generators/authentication/templates/controllers/api/password_resets_controller.rb.tt
36
37
  - lib/generators/authentication/templates/controllers/api/passwords_controller.rb.tt
37
38
  - lib/generators/authentication/templates/controllers/api/registrations_controller.rb.tt
38
39
  - lib/generators/authentication/templates/controllers/api/sessions_controller.rb.tt
39
40
  - lib/generators/authentication/templates/controllers/html/cancellations_controller.rb.tt
41
+ - lib/generators/authentication/templates/controllers/html/emails_controller.rb.tt
40
42
  - lib/generators/authentication/templates/controllers/html/password_resets_controller.rb.tt
41
43
  - lib/generators/authentication/templates/controllers/html/passwords_controller.rb.tt
42
44
  - lib/generators/authentication/templates/controllers/html/registrations_controller.rb.tt
43
45
  - lib/generators/authentication/templates/controllers/html/sessions_controller.rb.tt
46
+ - lib/generators/authentication/templates/mailers/email_mailer.rb.tt
44
47
  - lib/generators/authentication/templates/mailers/password_mailer.rb.tt
45
48
  - lib/generators/authentication/templates/migration.rb.tt
46
49
  - lib/generators/authentication/templates/models/current.rb.tt
47
50
  - lib/generators/authentication/templates/models/resource.rb.tt
48
51
  - lib/generators/authentication/templates/views/cancellations/new.html.erb.tt
52
+ - lib/generators/authentication/templates/views/email_mailer/changed.html.erb.tt
53
+ - lib/generators/authentication/templates/views/email_mailer/changed.text.erb.tt
54
+ - lib/generators/authentication/templates/views/emails/edit.html.erb.tt
55
+ - lib/generators/authentication/templates/views/password_mailer/changed.html.erb.tt
56
+ - lib/generators/authentication/templates/views/password_mailer/changed.text.erb.tt
49
57
  - lib/generators/authentication/templates/views/password_mailer/reset.html.erb.tt
50
58
  - lib/generators/authentication/templates/views/password_mailer/reset.text.erb.tt
51
59
  - lib/generators/authentication/templates/views/password_resets/edit.html.erb.tt