authentication-zero 0.0.8 → 0.0.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (22) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/README.md +2 -2
  4. data/lib/authentication_zero/version.rb +1 -1
  5. data/lib/generators/authentication/authentication_generator.rb +6 -11
  6. data/lib/generators/authentication/templates/controllers/api/cancellations_controller.rb.tt +1 -1
  7. data/lib/generators/authentication/templates/controllers/api/password_resets_controller.rb.tt +5 -4
  8. data/lib/generators/authentication/templates/controllers/api/passwords_controller.rb.tt +1 -1
  9. data/lib/generators/authentication/templates/controllers/api/registrations_controller.rb.tt +1 -1
  10. data/lib/generators/authentication/templates/controllers/html/cancellations_controller.rb.tt +1 -1
  11. data/lib/generators/authentication/templates/controllers/html/password_resets_controller.rb.tt +5 -4
  12. data/lib/generators/authentication/templates/controllers/html/passwords_controller.rb.tt +1 -1
  13. data/lib/generators/authentication/templates/mailers/password_mailer.rb.tt +1 -1
  14. data/lib/generators/authentication/templates/views/cancellations/new.html.erb.tt +2 -2
  15. data/lib/generators/authentication/templates/views/password_mailer/reset.html.erb.tt +8 -4
  16. data/lib/generators/authentication/templates/views/password_mailer/reset.text.erb.tt +6 -4
  17. data/lib/generators/authentication/templates/views/password_resets/edit.html.erb.tt +7 -11
  18. data/lib/generators/authentication/templates/views/password_resets/new.html.erb.tt +2 -9
  19. data/lib/generators/authentication/templates/views/passwords/edit.html.erb.tt +4 -3
  20. data/lib/generators/authentication/templates/views/registrations/new.html.erb.tt +2 -7
  21. data/lib/generators/authentication/templates/views/sessions/new.html.erb.tt +1 -1
  22. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 07c68a23f93d453c769787635ca42269f5f36e7c7a6b23aef28e7d99c530770e
4
- data.tar.gz: a636bcbea4839a311ece1ed5f9985f5b3c7802e10a90fe11a7a5a580c0383759
3
+ metadata.gz: c9a25e8862ad568105b15810d98b4efb68b1d7a69199c35ff7a726b991aeb21d
4
+ data.tar.gz: fd37bc06817fb23c8bd61c4cfe8635932be62ae94df89b5f5928f55b749e0a7d
5
5
  SHA512:
6
- metadata.gz: 44f612049c4a25d7db96bd68ddeb5905e8aeb44a5d077c2d23e908877720b99a059da1750743383710d8843946263752db4614b05b9bee30e7eba7c1303e1e59
7
- data.tar.gz: c08827199263f82df359d3d9fc4eeec04dd1087e2d24508ab531f8f55524cbab8af16cf3f2c5ca3d2099ff8da2a80b7988be6fe7affd8ca36b240035cbe74719
6
+ metadata.gz: 7c89d91c1e3b5259b2924b6c25ee09c094db9f71deb75944cf9387b45c7f3202cba8bc394539d1fc5c79038aeb5dbbbe74eed5b0ac4fd44c7f76377278380f24
7
+ data.tar.gz: 4f79e7af311270e7d995f8e07f3e2a73269c41b4fe17e31d7542e98547c96df4a6f55340d3575f05cd56e445582a9955443ca279ce8fe01f5fab4164d90c7d94
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- authentication-zero (0.0.8)
4
+ authentication-zero (0.0.12)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -31,11 +31,11 @@ Add these lines to your `app/views/home/index.html.erb`:
31
31
  <p>Signed as <%= Current.user.email %></p>
32
32
 
33
33
  <div>
34
- <%= link_to "Change password", password_edit_path %>
34
+ <%= link_to "Change password", edit_passwords_path %>
35
35
  </div>
36
36
 
37
37
  <div>
38
- <%= link_to "Cancel my account & delete my data", cancellation_new_path %>
38
+ <%= link_to "Cancel my account & delete my data", new_cancellations_path %>
39
39
  </div>
40
40
 
41
41
  <%= button_to "Log out", sign_out_path, method: :delete %>
@@ -1,3 +1,3 @@
1
1
  module AuthenticationZero
2
- VERSION = "0.0.8"
2
+ VERSION = "0.0.12"
3
3
  end
@@ -37,19 +37,14 @@ class AuthenticationGenerator < Rails::Generators::NamedBase
37
37
  end
38
38
 
39
39
  def add_routes
40
- route "get 'sign_up', to: 'registrations#new'" unless options.api?
40
+ route "resource :password_resets, only: [:new, :edit, :create, :update]"
41
+ route "resource :cancellations, only: [:new, :create]"
42
+ route "resource :passwords, only: [:update, :edit]"
43
+ route "delete 'sign_out', to: 'sessions#destroy'"
41
44
  route "post 'sign_up', to: 'registrations#create'"
42
- route "get 'sign_in', to: 'sessions#new'" unless options.api?
45
+ route "get 'sign_up', to: 'registrations#new'" unless options.api?
43
46
  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'"
47
+ route "get 'sign_in', to: 'sessions#new'" unless options.api?
53
48
  end
54
49
 
55
50
  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
@@ -1,9 +1,10 @@
1
1
  class PasswordResetsController < ApplicationController
2
- before_action :set_<%= singular_table_name %>, only: %i[ edit update ]
3
2
  skip_before_action :authenticate
4
3
 
4
+ before_action :set_<%= singular_table_name %>, only: %i[ edit update ]
5
+
5
6
  def edit
6
- render json: { message: "Open this link in your device" }, status: :not_found
7
+ render json: { error: "Open this link in your device" }, status: :not_found
7
8
  end
8
9
 
9
10
  def create
@@ -24,12 +25,12 @@ class PasswordResetsController < ApplicationController
24
25
 
25
26
  private
26
27
  def set_<%= singular_table_name %>
27
- @<%= singular_table_name %> = <%= class_name %>.find_signed!(params[:token], purpose: "password_reset")
28
+ @<%= singular_table_name %> = <%= class_name %>.find_signed!(params[:sid], purpose: "password_reset")
28
29
  rescue ActiveSupport::MessageVerifier::InvalidSignature
29
30
  render json: { error: "Your token has expired, please request a new one" }, status: :bad_request
30
31
  end
31
32
 
32
33
  def password_params
33
- params.require(:<%= singular_table_name %>).permit(:password, :password_confirmation)
34
+ params.permit(:password, :password_confirmation)
34
35
  end
35
36
  end
@@ -17,6 +17,6 @@ class PasswordsController < ApplicationController
17
17
  end
18
18
 
19
19
  def password_params
20
- params.require(:<%= singular_table_name %>).permit(:password, :password_confirmation)
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
@@ -1,7 +1,8 @@
1
1
  class PasswordResetsController < ApplicationController
2
- before_action :set_<%= singular_table_name %>, only: %i[ edit update ]
3
2
  skip_before_action :authenticate
4
3
 
4
+ before_action :set_<%= singular_table_name %>, only: %i[ edit update ]
5
+
5
6
  def new
6
7
  end
7
8
 
@@ -13,7 +14,7 @@ class PasswordResetsController < ApplicationController
13
14
  PasswordMailer.with(<%= singular_table_name %>: @<%= singular_table_name %>).reset.deliver_later
14
15
  redirect_to sign_in_path, notice: "You will receive an email with instructions on how to reset your password in a few minutes"
15
16
  else
16
- redirect_to password_reset_new_path, alert: "The email address doesn't exist in our database"
17
+ redirect_to new_password_resets_path, alert: "The email address doesn't exist in our database"
17
18
  end
18
19
  end
19
20
 
@@ -27,9 +28,9 @@ class PasswordResetsController < ApplicationController
27
28
 
28
29
  private
29
30
  def set_<%= singular_table_name %>
30
- @<%= singular_table_name %> = <%= class_name %>.find_signed!(params[:token], purpose: "password_reset")
31
+ @<%= singular_table_name %> = <%= class_name %>.find_signed!(params[:sid], purpose: "password_reset")
31
32
  rescue ActiveSupport::MessageVerifier::InvalidSignature
32
- redirect_to sign_in_path, alert: "Your token has expired, please request a new one"
33
+ redirect_to new_password_resets_path, alert: "Your token has expired, please request a new one"
33
34
  end
34
35
 
35
36
  def password_params
@@ -7,7 +7,7 @@ class PasswordsController < ApplicationController
7
7
 
8
8
  def update
9
9
  if !@<%= singular_table_name %>.authenticate(params[:current_password])
10
- redirect_to password_edit_path, alert: "The current password you entered is incorrect"
10
+ redirect_to edit_passwords_path, alert: "The current password you entered is incorrect"
11
11
  elsif @<%= singular_table_name %>.update(password_params)
12
12
  redirect_to root_path, notice: "Your password has been changed successfully"
13
13
  else
@@ -1,6 +1,6 @@
1
1
  class PasswordMailer < ApplicationMailer
2
2
  def reset
3
- @token = params[:<%= singular_table_name %>].signed_id(purpose: "password_reset", expires_in: 15.minutes)
3
+ @signed_id = params[:<%= singular_table_name %>].signed_id(purpose: "password_reset", expires_in: 20.minutes)
4
4
  mail to: params[:<%= singular_table_name %>].email
5
5
  end
6
6
  end
@@ -1,11 +1,11 @@
1
1
  <h1>Want to close your account?</h1>
2
2
 
3
- <p>Your account will be immediately closed. You wont be able to sign in anymore.</p>
3
+ <p>Your account will be immediately closed. You won't be able to sign in anymore.</p>
4
4
  <p>Your data will be permanently deleted from our servers.</p>
5
5
  <p><%%= link_to "Back", root_path %></p>
6
6
 
7
7
  <br>
8
8
 
9
9
  <div>
10
- <%%= button_to "OK, close my account", cancellation_path, method: :post %>
10
+ <%%= button_to "OK, close my account", cancellations_path %>
11
11
  </div>
@@ -1,7 +1,11 @@
1
- Hi <%%= params[:<%= singular_table_name %>].email %>,
1
+ <p>Hey there,</p>
2
2
 
3
- Someone requested a reset of your password.
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
- If this was you, click the link to reset your password. The link will expire automatically in 15 minutes.
5
+ <p><%%= link_to "Reset my password", edit_password_resets_url(sid: @signed_id) %></p>
6
6
 
7
- <%%= link_to "Reset password", password_reset_edit_url(token: @token) %>
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
+
9
+ <hr>
10
+
11
+ <p>Have questions or need help? Just reply to this email and our support team will help you sort it out.</p>
@@ -1,7 +1,9 @@
1
- Hi <%%= params[:<%= singular_table_name %>].email %>,
1
+ Hey there,
2
2
 
3
- Someone requested a reset of your password.
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
- If this was you, click the link to reset your password. The link will expire automatically in 15 minutes.
5
+ [Reset my password]<%%= edit_password_resets_url(sid: @signed_id) %>
6
6
 
7
- <%%= password_reset_edit_url(token: @token) %>
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
+
9
+ Have questions or need help? Just reply to this email and our support team will help you sort it out.
@@ -1,6 +1,6 @@
1
1
  <h1>Reset your password</h1>
2
2
 
3
- <%%= form_with(model: @<%= model_resource_name %>, url: password_reset_path(token: params[:token])) 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,24 +13,20 @@
13
13
  </div>
14
14
  <%% end %>
15
15
 
16
+ <%%= hidden_field_tag :sid, params[:sid] %>
17
+
16
18
  <div>
17
- <%%= form.label :password, "New password (8 characters minimum)", style: "display: block" %>
19
+ <%%= form.label :password, "New password", style: "display: block" %>
18
20
  <%%= form.password_field :password, autofocus: true, autocomplete: "new-password" %>
21
+ <div>8 characters minimum.</div>
19
22
  </div>
20
23
 
21
24
  <div>
22
- <%%= form.label :password_confirmation, style: "display: block" %>
25
+ <%%= form.label :password_confirmation, "Confirm new password", style: "display: block" %>
23
26
  <%%= form.password_field :password_confirmation, autocomplete: "new-password" %>
24
27
  </div>
25
28
 
26
29
  <div>
27
- <%%= form.submit "Reset password" %>
30
+ <%%= form.submit "Save changes" %>
28
31
  </div>
29
32
  <%% end %>
30
-
31
- <br>
32
-
33
- <div>
34
- <%%= link_to "Sign in", sign_in_path %> |
35
- <%%= link_to "Sign up", sign_up_path %>
36
- </div>
@@ -2,20 +2,13 @@
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
- <%%= form.email_field :email, autofocus: true, required: true, autocomplete: "email" %>
8
+ <%%= form.email_field :email, autofocus: true, required: true %>
9
9
  </div>
10
10
 
11
11
  <div>
12
12
  <%%= form.submit "Send password reset email" %>
13
13
  </div>
14
14
  <%% end %>
15
-
16
- <br>
17
-
18
- <div>
19
- <%%= link_to "Sign in", sign_in_path %> |
20
- <%%= link_to "Sign up", sign_up_path %>
21
- </div>
@@ -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>
@@ -21,12 +21,13 @@
21
21
  </div>
22
22
 
23
23
  <div>
24
- <%%= form.label :password, "New password (8 characters minimum)", style: "display: block" %>
24
+ <%%= form.label :password, "New password", style: "display: block" %>
25
25
  <%%= form.password_field :password, autocomplete: "new-password" %>
26
+ <div>8 characters minimum.</div>
26
27
  </div>
27
28
 
28
29
  <div>
29
- <%%= form.label :password_confirmation, style: "display: block" %>
30
+ <%%= form.label :password_confirmation, "Confirm new password", style: "display: block" %>
30
31
  <%%= form.password_field :password_confirmation, autocomplete: "new-password" %>
31
32
  </div>
32
33
 
@@ -19,8 +19,9 @@
19
19
  </div>
20
20
 
21
21
  <div>
22
- <%%= form.label :password, "Password (8 characters minimum)", style: "display: block" %>
22
+ <%%= form.label :password, style: "display: block" %>
23
23
  <%%= form.password_field :password, autocomplete: "new-password" %>
24
+ <div>8 characters minimum.</div>
24
25
  </div>
25
26
 
26
27
  <div>
@@ -32,9 +33,3 @@
32
33
  <%%= form.submit "Sign up" %>
33
34
  </div>
34
35
  <%% end %>
35
-
36
- <br>
37
-
38
- <div>
39
- <%%= link_to "Sign in", sign_in_path %>
40
- </div>
@@ -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.8
4
+ version: 0.0.12
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-15 00:00:00.000000000 Z
11
+ date: 2022-02-17 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: