authentication-zero 0.0.22 → 0.0.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +2 -1
- data/lib/authentication_zero/version.rb +1 -1
- data/lib/generators/authentication/USAGE +7 -2
- data/lib/generators/authentication/authentication_generator.rb +62 -48
- data/lib/generators/authentication/templates/{controllers → app/controllers}/api/cancellations_controller.rb.tt +0 -0
- data/lib/generators/authentication/templates/{controllers → app/controllers}/api/emails_controller.rb.tt +0 -0
- data/lib/generators/authentication/templates/{controllers → app/controllers}/api/password_resets_controller.rb.tt +1 -1
- data/lib/generators/authentication/templates/{controllers → app/controllers}/api/passwords_controller.rb.tt +0 -0
- data/lib/generators/authentication/templates/{controllers → app/controllers}/api/registrations_controller.rb.tt +0 -0
- data/lib/generators/authentication/templates/{controllers → app/controllers}/api/sessions_controller.rb.tt +1 -1
- data/lib/generators/authentication/templates/{controllers → app/controllers}/html/cancellations_controller.rb.tt +0 -0
- data/lib/generators/authentication/templates/{controllers → app/controllers}/html/emails_controller.rb.tt +0 -0
- data/lib/generators/authentication/templates/{controllers → app/controllers}/html/password_resets_controller.rb.tt +0 -0
- data/lib/generators/authentication/templates/{controllers → app/controllers}/html/passwords_controller.rb.tt +0 -0
- data/lib/generators/authentication/templates/{controllers → app/controllers}/html/registrations_controller.rb.tt +0 -0
- data/lib/generators/authentication/templates/{controllers → app/controllers}/html/sessions_controller.rb.tt +0 -0
- data/lib/generators/authentication/templates/{mailers → app/mailers}/email_mailer.rb.tt +0 -0
- data/lib/generators/authentication/templates/{mailers → app/mailers}/password_mailer.rb.tt +0 -0
- data/lib/generators/authentication/templates/{models → app/models}/current.rb.tt +0 -0
- data/lib/generators/authentication/templates/{models/resource.rb.tt → app/models/model.rb.tt} +6 -3
- data/lib/generators/authentication/templates/{views → app/views}/cancellations/new.html.erb.tt +0 -0
- data/lib/generators/authentication/templates/{views → app/views}/email_mailer/changed.html.erb.tt +0 -0
- data/lib/generators/authentication/templates/{views → app/views}/email_mailer/changed.text.erb.tt +0 -0
- data/lib/generators/authentication/templates/{views → app/views}/emails/edit.html.erb.tt +0 -0
- data/lib/generators/authentication/templates/{views → app/views}/password_mailer/changed.html.erb.tt +0 -0
- data/lib/generators/authentication/templates/{views → app/views}/password_mailer/changed.text.erb.tt +0 -0
- data/lib/generators/authentication/templates/{views → app/views}/password_mailer/reset.html.erb.tt +0 -0
- data/lib/generators/authentication/templates/{views → app/views}/password_mailer/reset.text.erb.tt +0 -0
- data/lib/generators/authentication/templates/{views → app/views}/password_resets/edit.html.erb.tt +0 -0
- data/lib/generators/authentication/templates/{views → app/views}/password_resets/new.html.erb.tt +0 -0
- data/lib/generators/authentication/templates/{views → app/views}/passwords/edit.html.erb.tt +0 -0
- data/lib/generators/authentication/templates/{views → app/views}/registrations/new.html.erb.tt +0 -0
- data/lib/generators/authentication/templates/{views → app/views}/sessions/new.html.erb.tt +0 -0
- data/lib/generators/authentication/templates/test_unit/controllers/api/cancellations_controller_test.rb.tt +20 -0
- data/lib/generators/authentication/templates/test_unit/controllers/api/emails_controller_test.rb.tt +29 -0
- data/lib/generators/authentication/templates/test_unit/controllers/api/password_resets_controller_test.rb.tt +46 -0
- data/lib/generators/authentication/templates/test_unit/controllers/api/passwords_controller_test.rb.tt +29 -0
- data/lib/generators/authentication/templates/test_unit/controllers/api/registrations_controller_test.rb.tt +11 -0
- data/lib/generators/authentication/templates/test_unit/controllers/api/sessions_controller_test.rb.tt +29 -0
- data/lib/generators/authentication/templates/test_unit/controllers/html/cancellations_controller_test.rb.tt +24 -0
- data/lib/generators/authentication/templates/test_unit/controllers/html/emails_controller_test.rb.tt +33 -0
- data/lib/generators/authentication/templates/test_unit/controllers/html/password_resets_controller_test.rb.tt +49 -0
- data/lib/generators/authentication/templates/test_unit/controllers/html/passwords_controller_test.rb.tt +33 -0
- data/lib/generators/authentication/templates/test_unit/controllers/html/registrations_controller_test.rb.tt +18 -0
- data/lib/generators/authentication/templates/test_unit/controllers/html/sessions_controller_test.rb.tt +45 -0
- data/lib/generators/authentication/templates/test_unit/fixtures.yml.tt +6 -0
- data/lib/generators/authentication/templates/test_unit/system/cancellations_test.rb.tt +23 -0
- data/lib/generators/authentication/templates/test_unit/system/emails_test.rb.tt +26 -0
- data/lib/generators/authentication/templates/test_unit/system/password_resets_test.rb.tt +28 -0
- data/lib/generators/authentication/templates/test_unit/system/passwords_test.rb.tt +27 -0
- data/lib/generators/authentication/templates/test_unit/system/registrations_test.rb.tt +15 -0
- data/lib/generators/authentication/templates/test_unit/system/sessions_test.rb.tt +32 -0
- metadata +50 -32
- data/lib/generators/authentication/templates/migration.rb.tt +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 78818129456d7a394a2a456605b007a2d0d68203038bb79ac0a8d9b74a9de59d
|
4
|
+
data.tar.gz: 7a7b8485f5c7cb9d3573e1768e25b40ba2de04fcf27d97d2383696ffabdb2249
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 23bf695588244691a1a9db956f0f096e785ecd83bba969d05c7ee109b00a3a97c30a6ad13b3f874ac1f783f49181b0bdd92ff7f9cfa31b05ae223af1734ab420
|
7
|
+
data.tar.gz: 0b360acf0cb305053ca5610cb2a7de73ba3a2b2a091090ddd770f7ca99daa0e2ad48e5eebdba9d1e216e13418f4ff6c93802403f5c5f12de0ee7e0c0de42fb01
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -26,13 +26,14 @@ The purpose of authentication zero is to generate a pre-built authentication sys
|
|
26
26
|
- [Callbacks](https://api.rubyonrails.org/classes/ActiveRecord/Callbacks.html): We use callbacks to send emails after changing an email or password.
|
27
27
|
- [Action mailer](https://api.rubyonrails.org/classes/ActionMailer/Base.html): Action Mailer allows you to send email from your application using a mailer model and views.
|
28
28
|
- [Log filtering](https://guides.rubyonrails.org/action_controller_overview.html#log-filtering): Parameters 'token' and 'password' are marked [FILTERED] in the log.
|
29
|
+
- [Functional Tests](https://guides.rubyonrails.org/testing.html#functional-tests-for-your-controllers): In Rails, testing the various actions of a controller is a form of writing functional tests.
|
30
|
+
- [System Testing][https://guides.rubyonrails.org/testing.html#system-testing]: System tests allow you to test user interactions with your application, running tests in either a real or a headless browser.
|
29
31
|
|
30
32
|
## Installation
|
31
33
|
|
32
34
|
Add this lines to your application's Gemfile:
|
33
35
|
|
34
36
|
```ruby
|
35
|
-
gem "bcrypt"
|
36
37
|
gem "authentication-zero"
|
37
38
|
```
|
38
39
|
|
@@ -1,6 +1,11 @@
|
|
1
1
|
Description:
|
2
|
-
The purpose of authentication zero is to generate a pre-built
|
3
|
-
|
2
|
+
The purpose of authentication zero is to generate a pre-built
|
3
|
+
authentication system into a rails application that
|
4
|
+
follows both security and rails best practices.
|
5
|
+
|
6
|
+
By generating code into the user's application
|
7
|
+
instead of using a library, the user has complete freedom
|
8
|
+
to modify the authentication system so it works best with their app.
|
4
9
|
|
5
10
|
Example:
|
6
11
|
bin/rails generate authentication user
|
@@ -4,38 +4,74 @@ class AuthenticationGenerator < Rails::Generators::NamedBase
|
|
4
4
|
include ActiveRecord::Generators::Migration
|
5
5
|
|
6
6
|
class_option :api, type: :boolean, desc: "Generates API authentication"
|
7
|
+
class_option :system_tests, type: :string, desc: "Skip system test files"
|
7
8
|
|
8
9
|
source_root File.expand_path("templates", __dir__)
|
9
10
|
|
10
|
-
def
|
11
|
-
|
12
|
-
directory "controllers/api", "app/controllers"
|
13
|
-
else
|
14
|
-
directory "controllers/html", "app/controllers"
|
15
|
-
end
|
11
|
+
def add_bcrypt
|
12
|
+
uncomment_lines 'Gemfile', /bcrypt/
|
16
13
|
end
|
17
14
|
|
18
|
-
def
|
19
|
-
|
20
|
-
|
15
|
+
def create_migrations
|
16
|
+
invoke "migration", ["create_#{table_name}", "email:string:uniq", "password_digest:string", "session_token:string:uniq"]
|
17
|
+
end
|
18
|
+
|
19
|
+
def create_models
|
20
|
+
template "app/models/model.rb", "app/models/#{file_name}.rb"
|
21
|
+
template "app/models/current.rb", "app/models/current.rb"
|
22
|
+
end
|
23
|
+
|
24
|
+
def create_fixture_file
|
25
|
+
template "test_unit/fixtures.yml", "test/fixtures/#{fixture_file_name}.yml"
|
26
|
+
end
|
27
|
+
|
28
|
+
def add_application_controller_methods
|
29
|
+
api_code = <<~CODE
|
30
|
+
include ActionController::HttpAuthentication::Token::ControllerMethods
|
31
|
+
|
32
|
+
before_action :authenticate
|
33
|
+
|
34
|
+
private
|
35
|
+
def authenticate
|
36
|
+
authenticate_or_request_with_http_token do |token, _options|
|
37
|
+
Current.#{singular_table_name} = #{class_name}.find_signed_session_token(token)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
CODE
|
41
|
+
|
42
|
+
html_code = <<~CODE
|
43
|
+
before_action :authenticate
|
44
|
+
|
45
|
+
private
|
46
|
+
def authenticate
|
47
|
+
if #{singular_table_name} = #{class_name}.find_by_session_token(cookies.signed[:session_token])
|
48
|
+
Current.#{singular_table_name} = #{singular_table_name}
|
49
|
+
else
|
50
|
+
redirect_to sign_in_path, alert: "You need to sign in or sign up before continuing"
|
51
|
+
end
|
52
|
+
end
|
53
|
+
CODE
|
54
|
+
|
55
|
+
inject_code = options.api? ? api_code : html_code
|
56
|
+
inject_into_class "app/controllers/application_controller.rb", "ApplicationController", optimize_indentation(inject_code, 2), verbose: false
|
57
|
+
end
|
58
|
+
|
59
|
+
def create_controllers
|
60
|
+
directory "app/controllers/#{format_folder}", "app/controllers"
|
21
61
|
end
|
22
62
|
|
23
63
|
def create_views
|
24
64
|
if options.api
|
25
|
-
directory "views/email_mailer", "app/views/email_mailer"
|
26
|
-
directory "views/password_mailer", "app/views/password_mailer"
|
65
|
+
directory "app/views/email_mailer", "app/views/email_mailer"
|
66
|
+
directory "app/views/password_mailer", "app/views/password_mailer"
|
27
67
|
else
|
28
|
-
directory "views", "app/views"
|
68
|
+
directory "app/views", "app/views"
|
29
69
|
end
|
30
70
|
end
|
31
71
|
|
32
|
-
def
|
33
|
-
template "
|
34
|
-
template "
|
35
|
-
end
|
36
|
-
|
37
|
-
def create_migrations
|
38
|
-
migration_template "migration.rb", "#{db_migrate_path}/create_#{file_name}.rb"
|
72
|
+
def create_mailers
|
73
|
+
template "app/mailers/email_mailer.rb", "app/mailers/email_mailer.rb"
|
74
|
+
template "app/mailers/password_mailer.rb", "app/mailers/password_mailer.rb"
|
39
75
|
end
|
40
76
|
|
41
77
|
def add_routes
|
@@ -50,35 +86,13 @@ class AuthenticationGenerator < Rails::Generators::NamedBase
|
|
50
86
|
route "get 'sign_in', to: 'sessions#new'" unless options.api?
|
51
87
|
end
|
52
88
|
|
53
|
-
def
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
before_action :authenticate
|
89
|
+
def create_test_files
|
90
|
+
directory "test_unit/controllers/#{format_folder}", "test/controllers"
|
91
|
+
directory "test_unit/system", "test/system" if !options.api? && options[:system_tests]
|
92
|
+
end
|
59
93
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
Current.#{singular_table_name} = #{class_name}.find_signed_session_token(token)
|
64
|
-
end
|
65
|
-
end
|
66
|
-
CODE
|
67
|
-
end
|
68
|
-
else
|
69
|
-
inject_into_class "app/controllers/application_controller.rb", "ApplicationController", verbose: false do <<~CODE
|
70
|
-
before_action :authenticate
|
71
|
-
|
72
|
-
private
|
73
|
-
def authenticate
|
74
|
-
if #{singular_table_name} = #{class_name}.find_by_session_token(cookies.signed[:session_token])
|
75
|
-
Current.#{singular_table_name} = #{singular_table_name}
|
76
|
-
else
|
77
|
-
redirect_to sign_in_path, alert: "You need to sign in or sign up before continuing"
|
78
|
-
end
|
79
|
-
end
|
80
|
-
CODE
|
81
|
-
end
|
94
|
+
private
|
95
|
+
def format_folder
|
96
|
+
options.api ? "api" : "html"
|
82
97
|
end
|
83
|
-
end
|
84
98
|
end
|
File without changes
|
File without changes
|
@@ -10,7 +10,7 @@ class PasswordResetsController < ApplicationController
|
|
10
10
|
if @<%= singular_table_name %> = <%= class_name %>.find_by_email(params[:email])
|
11
11
|
PasswordMailer.with(<%= singular_table_name %>: @<%= singular_table_name %>).reset.deliver_later
|
12
12
|
else
|
13
|
-
render json: { error: "The email address doesn't exist in our database" }, status: :
|
13
|
+
render json: { error: "The email address doesn't exist in our database" }, status: :not_found
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
File without changes
|
File without changes
|
@@ -5,7 +5,7 @@ class SessionsController < ApplicationController
|
|
5
5
|
@<%= singular_table_name %> = <%= class_name %>.find_by_email(params[:email])
|
6
6
|
|
7
7
|
if @<%= singular_table_name %>.try(:authenticate, params[:password])
|
8
|
-
render json: { session_token: @<%= singular_table_name %>.signed_session_token }
|
8
|
+
render json: { session_token: @<%= singular_table_name %>.signed_session_token }, status: :ok
|
9
9
|
else
|
10
10
|
render json: { error: "Invalid email or password" }, status: :unauthorized
|
11
11
|
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/lib/generators/authentication/templates/{models/resource.rb.tt → app/models/model.rb.tt}
RENAMED
@@ -1,6 +1,6 @@
|
|
1
1
|
class <%= class_name %> < ApplicationRecord
|
2
|
-
has_secure_password :password
|
3
2
|
has_secure_token :session_token
|
3
|
+
has_secure_password
|
4
4
|
|
5
5
|
validates :email, presence: true, uniqueness: true
|
6
6
|
validates :email, format: { with: /\A[^@\s]+@[^@\s]+\z/ }
|
@@ -21,8 +21,7 @@ class <%= class_name %> < ApplicationRecord
|
|
21
21
|
PasswordMailer.with(<%= singular_table_name %>: self).changed.deliver_later
|
22
22
|
end
|
23
23
|
end
|
24
|
-
|
25
|
-
<% if options.api? -%>
|
24
|
+
<% if options.api? %>
|
26
25
|
def signed_session_token
|
27
26
|
self.class.signed_id_verifier.generate(session_token)
|
28
27
|
end
|
@@ -32,5 +31,9 @@ class <%= class_name %> < ApplicationRecord
|
|
32
31
|
find_by_session_token(session_token)
|
33
32
|
end
|
34
33
|
end
|
34
|
+
|
35
|
+
def as_json(options = {})
|
36
|
+
super(options.merge(except: [:password_digest, :session_token]))
|
37
|
+
end
|
35
38
|
<% end -%>
|
36
39
|
end
|
data/lib/generators/authentication/templates/{views → app/views}/cancellations/new.html.erb.tt
RENAMED
File without changes
|
data/lib/generators/authentication/templates/{views → app/views}/email_mailer/changed.html.erb.tt
RENAMED
File without changes
|
data/lib/generators/authentication/templates/{views → app/views}/email_mailer/changed.text.erb.tt
RENAMED
File without changes
|
File without changes
|
data/lib/generators/authentication/templates/{views → app/views}/password_mailer/changed.html.erb.tt
RENAMED
File without changes
|
data/lib/generators/authentication/templates/{views → app/views}/password_mailer/changed.text.erb.tt
RENAMED
File without changes
|
data/lib/generators/authentication/templates/{views → app/views}/password_mailer/reset.html.erb.tt
RENAMED
File without changes
|
data/lib/generators/authentication/templates/{views → app/views}/password_mailer/reset.text.erb.tt
RENAMED
File without changes
|
data/lib/generators/authentication/templates/{views → app/views}/password_resets/edit.html.erb.tt
RENAMED
File without changes
|
data/lib/generators/authentication/templates/{views → app/views}/password_resets/new.html.erb.tt
RENAMED
File without changes
|
File without changes
|
data/lib/generators/authentication/templates/{views → app/views}/registrations/new.html.erb.tt
RENAMED
File without changes
|
File without changes
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class CancellationsControllerTest < ActionDispatch::IntegrationTest
|
4
|
+
setup do
|
5
|
+
@<%= singular_table_name %>, @token = sign_in_as(<%= table_name %>(:lazaro_nixon))
|
6
|
+
end
|
7
|
+
|
8
|
+
test "should create cancellation" do
|
9
|
+
assert_difference("<%= class_name %>.count", -1) do
|
10
|
+
post cancellations_url, headers: { "Authorization" => "Bearer #{@token}" }
|
11
|
+
end
|
12
|
+
|
13
|
+
assert_response :no_content
|
14
|
+
end
|
15
|
+
|
16
|
+
def sign_in_as(<%= singular_table_name %>)
|
17
|
+
post(sign_in_url, params: { email: <%= singular_table_name %>.email, password: "secret123" })
|
18
|
+
[<%= singular_table_name %>, response.parsed_body["session_token"]]
|
19
|
+
end
|
20
|
+
end
|
data/lib/generators/authentication/templates/test_unit/controllers/api/emails_controller_test.rb.tt
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class EmailsControllerTest < ActionDispatch::IntegrationTest
|
4
|
+
setup do
|
5
|
+
@<%= singular_table_name %>, @token = sign_in_as(<%= table_name %>(:lazaro_nixon))
|
6
|
+
end
|
7
|
+
|
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
|
+
|
13
|
+
assert_response :success
|
14
|
+
end
|
15
|
+
|
16
|
+
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
|
20
|
+
|
21
|
+
assert_response :bad_request
|
22
|
+
assert_equal "The current password you entered is incorrect", response.parsed_body["error"]
|
23
|
+
end
|
24
|
+
|
25
|
+
def sign_in_as(<%= singular_table_name %>)
|
26
|
+
post(sign_in_url, params: { email: <%= singular_table_name %>.email, password: "secret123" })
|
27
|
+
[<%= singular_table_name %>, response.parsed_body["session_token"]]
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class PasswordResetsControllerTest < ActionDispatch::IntegrationTest
|
4
|
+
setup do
|
5
|
+
@<%= singular_table_name %> = <%= table_name %>(:lazaro_nixon)
|
6
|
+
@sid = @<%= singular_table_name %>.signed_id(purpose: "password_reset", expires_in: 20.minutes)
|
7
|
+
@sid_exp = @<%= singular_table_name %>.signed_id(purpose: "password_reset", expires_in: 0.minutes)
|
8
|
+
end
|
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
|
+
test "should send a password reset email" do
|
18
|
+
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 }
|
20
|
+
end
|
21
|
+
|
22
|
+
assert_response :no_content
|
23
|
+
end
|
24
|
+
|
25
|
+
test "should not send a password reset email to a nonexistent email" do
|
26
|
+
assert_no_enqueued_emails do
|
27
|
+
post password_resets_url, params: { email: "invalid_email@hey.com" }
|
28
|
+
end
|
29
|
+
|
30
|
+
assert_response :not_found
|
31
|
+
assert_equal "The email address doesn't exist in our database", response.parsed_body["error"]
|
32
|
+
end
|
33
|
+
|
34
|
+
test "should update password" do
|
35
|
+
patch password_resets_url, params: { token: @sid, password: "new_password", password_confirmation: "new_password" }
|
36
|
+
|
37
|
+
assert_response :success
|
38
|
+
end
|
39
|
+
|
40
|
+
test "should not update password with expired token" do
|
41
|
+
patch password_resets_url, params: { token: @sid_exp, password: "new_password", password_confirmation: "new_password" }
|
42
|
+
|
43
|
+
assert_response :bad_request
|
44
|
+
assert_equal "Your token has expired, please request a new one", response.parsed_body["error"]
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class PasswordsControllerTest < ActionDispatch::IntegrationTest
|
4
|
+
setup do
|
5
|
+
@<%= singular_table_name %>, @token = sign_in_as(<%= table_name %>(:lazaro_nixon))
|
6
|
+
end
|
7
|
+
|
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
|
+
|
13
|
+
assert_response :success
|
14
|
+
end
|
15
|
+
|
16
|
+
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
|
20
|
+
|
21
|
+
assert_response :bad_request
|
22
|
+
assert_equal "The current password you entered is incorrect", response.parsed_body["error"]
|
23
|
+
end
|
24
|
+
|
25
|
+
def sign_in_as(<%= singular_table_name %>)
|
26
|
+
post(sign_in_url, params: { email: <%= singular_table_name %>.email, password: "secret123" })
|
27
|
+
[<%= singular_table_name %>, response.parsed_body["session_token"]]
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class RegistrationsControllerTest < ActionDispatch::IntegrationTest
|
4
|
+
test "should sign up" do
|
5
|
+
assert_difference("<%= class_name %>.count") do
|
6
|
+
post sign_up_url, params: { email: "lazaronixon@hey.com", password: "secret123", password_confirmation: "secret123" }
|
7
|
+
end
|
8
|
+
|
9
|
+
assert_response :created
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class SessionsControllerTest < ActionDispatch::IntegrationTest
|
4
|
+
setup do
|
5
|
+
@<%= singular_table_name %> = <%= table_name %>(:lazaro_nixon)
|
6
|
+
end
|
7
|
+
|
8
|
+
test "should sign in" do
|
9
|
+
post sign_in_url, params: { email: @<%= singular_table_name %>.email, password: "secret123" }
|
10
|
+
assert_response :success
|
11
|
+
end
|
12
|
+
|
13
|
+
test "should not sign in with wrong credentials" do
|
14
|
+
post sign_in_url, params: { email: @<%= singular_table_name %>.email, password: "wrong_password" }
|
15
|
+
assert_response :unauthorized
|
16
|
+
end
|
17
|
+
|
18
|
+
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}" }
|
22
|
+
assert_response :no_content
|
23
|
+
end
|
24
|
+
|
25
|
+
def sign_in_as(<%= singular_table_name %>)
|
26
|
+
post(sign_in_url, params: { email: <%= singular_table_name %>.email, password: "secret123" })
|
27
|
+
[<%= singular_table_name %>, response.parsed_body["session_token"]]
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class CancellationsControllerTest < ActionDispatch::IntegrationTest
|
4
|
+
setup do
|
5
|
+
@<%= singular_table_name %> = sign_in_as(<%= table_name %>(:lazaro_nixon))
|
6
|
+
end
|
7
|
+
|
8
|
+
test "should get new" do
|
9
|
+
get new_cancellations_url
|
10
|
+
assert_response :success
|
11
|
+
end
|
12
|
+
|
13
|
+
test "should create cancellation" do
|
14
|
+
assert_difference("<%= class_name %>.count", -1) do
|
15
|
+
post cancellations_url
|
16
|
+
end
|
17
|
+
|
18
|
+
assert_redirected_to sign_in_url
|
19
|
+
end
|
20
|
+
|
21
|
+
def sign_in_as(<%= singular_table_name %>)
|
22
|
+
post(sign_in_url, params: { email: <%= singular_table_name %>.email, password: "secret123" }); user
|
23
|
+
end
|
24
|
+
end
|
data/lib/generators/authentication/templates/test_unit/controllers/html/emails_controller_test.rb.tt
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class EmailsControllerTest < ActionDispatch::IntegrationTest
|
4
|
+
setup do
|
5
|
+
@<%= singular_table_name %> = sign_in_as(<%= table_name %>(:lazaro_nixon))
|
6
|
+
end
|
7
|
+
|
8
|
+
test "should get edit" do
|
9
|
+
get edit_emails_url
|
10
|
+
assert_response :success
|
11
|
+
end
|
12
|
+
|
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
|
+
|
18
|
+
assert_redirected_to root_path
|
19
|
+
end
|
20
|
+
|
21
|
+
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
|
25
|
+
|
26
|
+
assert_redirected_to edit_emails_path
|
27
|
+
assert_equal "The current password you entered is incorrect", flash[:alert]
|
28
|
+
end
|
29
|
+
|
30
|
+
def sign_in_as(<%= singular_table_name %>)
|
31
|
+
post(sign_in_url, params: { email: <%= singular_table_name %>.email, password: "secret123" }); user
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class PasswordResetsControllerTest < ActionDispatch::IntegrationTest
|
4
|
+
setup do
|
5
|
+
@<%= singular_table_name %> = <%= table_name %>(:lazaro_nixon)
|
6
|
+
@sid = @<%= singular_table_name %>.signed_id(purpose: "password_reset", expires_in: 20.minutes)
|
7
|
+
@sid_exp = @<%= singular_table_name %>.signed_id(purpose: "password_reset", expires_in: 0.minutes)
|
8
|
+
end
|
9
|
+
|
10
|
+
test "should get new" do
|
11
|
+
get new_password_resets_url
|
12
|
+
assert_response :success
|
13
|
+
end
|
14
|
+
|
15
|
+
test "should get edit" do
|
16
|
+
get edit_password_resets_url(token: @sid)
|
17
|
+
assert_response :success
|
18
|
+
end
|
19
|
+
|
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 }
|
23
|
+
end
|
24
|
+
|
25
|
+
assert_redirected_to sign_in_path
|
26
|
+
end
|
27
|
+
|
28
|
+
test "should not send a password reset email to a nonexistent email" do
|
29
|
+
assert_no_enqueued_emails do
|
30
|
+
post password_resets_url, params: { email: "invalid_email@hey.com" }
|
31
|
+
end
|
32
|
+
|
33
|
+
assert_redirected_to new_password_resets_url(email_hint: "invalid_email@hey.com")
|
34
|
+
assert_equal "The email address doesn't exist in our database", flash[:alert]
|
35
|
+
end
|
36
|
+
|
37
|
+
test "should update password" do
|
38
|
+
patch password_resets_url, params: { token: @sid, <%= singular_table_name %>: { password: "new_password", password_confirmation: "new_password" } }
|
39
|
+
|
40
|
+
assert_redirected_to sign_in_path
|
41
|
+
end
|
42
|
+
|
43
|
+
test "should not update password with expired token" do
|
44
|
+
patch password_resets_url, params: { token: @sid_exp, password: "new_password", password_confirmation: "new_password" }
|
45
|
+
|
46
|
+
assert_redirected_to new_password_resets_path
|
47
|
+
assert_equal "Your token has expired, please request a new one", flash[:alert]
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class PasswordsControllerTest < ActionDispatch::IntegrationTest
|
4
|
+
setup do
|
5
|
+
@<%= singular_table_name %> = sign_in_as(<%= table_name %>(:lazaro_nixon))
|
6
|
+
end
|
7
|
+
|
8
|
+
test "should get edit" do
|
9
|
+
get edit_passwords_url
|
10
|
+
assert_response :success
|
11
|
+
end
|
12
|
+
|
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
|
+
|
18
|
+
assert_redirected_to root_path
|
19
|
+
end
|
20
|
+
|
21
|
+
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
|
25
|
+
|
26
|
+
assert_redirected_to edit_passwords_path
|
27
|
+
assert_equal "The current password you entered is incorrect", flash[:alert]
|
28
|
+
end
|
29
|
+
|
30
|
+
def sign_in_as(<%= singular_table_name %>)
|
31
|
+
post(sign_in_url, params: { email: <%= singular_table_name %>.email, password: "secret123" }); user
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class RegistrationsControllerTest < ActionDispatch::IntegrationTest
|
4
|
+
test "should get new" do
|
5
|
+
get sign_up_url
|
6
|
+
assert_response :success
|
7
|
+
end
|
8
|
+
|
9
|
+
test "should sign up" do
|
10
|
+
assert_difference("<%= class_name %>.count") do
|
11
|
+
post sign_up_url, params: { <%= singular_table_name %>: { email: "lazaronixon@hey.com", password: "secret123", password_confirmation: "secret123" } }
|
12
|
+
end
|
13
|
+
assert_redirected_to root_url
|
14
|
+
|
15
|
+
follow_redirect!
|
16
|
+
assert_response :success
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class SessionsControllerTest < ActionDispatch::IntegrationTest
|
4
|
+
setup do
|
5
|
+
@<%= singular_table_name %> = <%= table_name %>(:lazaro_nixon)
|
6
|
+
end
|
7
|
+
|
8
|
+
test "should get new" do
|
9
|
+
get sign_in_url
|
10
|
+
assert_response :success
|
11
|
+
end
|
12
|
+
|
13
|
+
test "should sign in" do
|
14
|
+
post sign_in_url, params: { email: @<%= singular_table_name %>.email, password: "secret123" }
|
15
|
+
assert_redirected_to root_url
|
16
|
+
|
17
|
+
get root_url
|
18
|
+
assert_response :success
|
19
|
+
end
|
20
|
+
|
21
|
+
test "should not sign in with wrong credentials" do
|
22
|
+
post sign_in_url, params: { email: @<%= singular_table_name %>.email, password: "wrong_password" }
|
23
|
+
assert_redirected_to sign_in_url(email_hint: @<%= singular_table_name %>.email)
|
24
|
+
assert_equal "Invalid email or password", flash[:alert]
|
25
|
+
|
26
|
+
get root_url
|
27
|
+
assert_redirected_to sign_in_path
|
28
|
+
assert_equal "You need to sign in or sign up before continuing", flash[:alert]
|
29
|
+
end
|
30
|
+
|
31
|
+
test "should sign out" do
|
32
|
+
sign_in_as @<%= singular_table_name %>
|
33
|
+
|
34
|
+
delete sign_out_url
|
35
|
+
assert_redirected_to sign_in_path
|
36
|
+
|
37
|
+
get root_path
|
38
|
+
assert_redirected_to sign_in_path
|
39
|
+
assert_equal "You need to sign in or sign up before continuing", flash[:alert]
|
40
|
+
end
|
41
|
+
|
42
|
+
def sign_in_as(<%= singular_table_name %>)
|
43
|
+
post(sign_in_url, params: { email: <%= singular_table_name %>.email, password: "secret123" }); user
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require "application_system_test_case"
|
2
|
+
|
3
|
+
class CancellationsTest < ApplicationSystemTestCase
|
4
|
+
setup do
|
5
|
+
@<%= singular_table_name %> = sign_in_as(<%= table_name %>(:lazaro_nixon))
|
6
|
+
end
|
7
|
+
|
8
|
+
test "cancelling my account" do
|
9
|
+
click_on "Cancel my account & delete my data"
|
10
|
+
click_on "OK, close my account"
|
11
|
+
|
12
|
+
assert_text "Bye! Your account has been successfully cancelled"
|
13
|
+
end
|
14
|
+
|
15
|
+
def sign_in_as(<%= singular_table_name %>)
|
16
|
+
visit sign_in_url
|
17
|
+
fill_in :email, with: <%= singular_table_name %>.email
|
18
|
+
fill_in :password, with: "secret123"
|
19
|
+
click_on "Sign in"
|
20
|
+
|
21
|
+
return <%= singular_table_name %>
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require "application_system_test_case"
|
2
|
+
|
3
|
+
class EmailsTest < ApplicationSystemTestCase
|
4
|
+
setup do
|
5
|
+
@<%= singular_table_name %> = sign_in_as(<%= table_name %>(:lazaro_nixon))
|
6
|
+
end
|
7
|
+
|
8
|
+
test "updating the email" do
|
9
|
+
click_on "Change email"
|
10
|
+
|
11
|
+
fill_in "Current password", with: "secret123"
|
12
|
+
fill_in "New email", with: "new_email@hey.com"
|
13
|
+
click_on "Save changes"
|
14
|
+
|
15
|
+
assert_text "Your email has been changed successfully"
|
16
|
+
end
|
17
|
+
|
18
|
+
def sign_in_as(<%= singular_table_name %>)
|
19
|
+
visit sign_in_url
|
20
|
+
fill_in :email, with: <%= singular_table_name %>.email
|
21
|
+
fill_in :password, with: "secret123"
|
22
|
+
click_on "Sign in"
|
23
|
+
|
24
|
+
return <%= singular_table_name %>
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require "application_system_test_case"
|
2
|
+
|
3
|
+
class PasswordResetsTest < ApplicationSystemTestCase
|
4
|
+
setup do
|
5
|
+
@<%= singular_table_name %> = <%= table_name %>(:lazaro_nixon)
|
6
|
+
@sid = @<%= singular_table_name %>.signed_id(purpose: "password_reset", expires_in: 20.minutes)
|
7
|
+
end
|
8
|
+
|
9
|
+
test "sending a password reset email" do
|
10
|
+
visit sign_in_url
|
11
|
+
click_on "Forgot your password?"
|
12
|
+
|
13
|
+
fill_in "Email", with: @<%= singular_table_name %>.email
|
14
|
+
click_on "Send password reset email"
|
15
|
+
|
16
|
+
assert_text "You will receive an email with instructions on how to reset your password in a few minutes"
|
17
|
+
end
|
18
|
+
|
19
|
+
test "updating password" do
|
20
|
+
visit edit_password_resets_url(token: @sid)
|
21
|
+
|
22
|
+
fill_in "New password", with: "new_password"
|
23
|
+
fill_in "Confirm new password", with: "new_password"
|
24
|
+
click_on "Save changes"
|
25
|
+
|
26
|
+
assert_text "Your password was reset successfully. Please sign in"
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require "application_system_test_case"
|
2
|
+
|
3
|
+
class PasswordsTest < ApplicationSystemTestCase
|
4
|
+
setup do
|
5
|
+
@<%= singular_table_name %> = sign_in_as(<%= table_name %>(:lazaro_nixon))
|
6
|
+
end
|
7
|
+
|
8
|
+
test "updating the password" do
|
9
|
+
click_on "Change password"
|
10
|
+
|
11
|
+
fill_in "Current password", with: "secret123"
|
12
|
+
fill_in "New password", with: "new_password"
|
13
|
+
fill_in "Confirm new password", with: "new_password"
|
14
|
+
click_on "Save changes"
|
15
|
+
|
16
|
+
assert_text "Your password has been changed successfully"
|
17
|
+
end
|
18
|
+
|
19
|
+
def sign_in_as(<%= singular_table_name %>)
|
20
|
+
visit sign_in_url
|
21
|
+
fill_in :email, with: <%= singular_table_name %>.email
|
22
|
+
fill_in :password, with: "secret123"
|
23
|
+
click_on "Sign in"
|
24
|
+
|
25
|
+
return <%= singular_table_name %>
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require "application_system_test_case"
|
2
|
+
|
3
|
+
class RegistrationsTest < ApplicationSystemTestCase
|
4
|
+
test "signing up" do
|
5
|
+
visit sign_in_url
|
6
|
+
click_on "Sign up"
|
7
|
+
|
8
|
+
fill_in "Email", with: "lazaronixon@hey.com"
|
9
|
+
fill_in "Password", with: "new_password"
|
10
|
+
fill_in "Password confirmation", with: "new_password"
|
11
|
+
click_on "Sign up"
|
12
|
+
|
13
|
+
assert_text "Welcome! You have signed up successfully"
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require "application_system_test_case"
|
2
|
+
|
3
|
+
class SessionsTest < ApplicationSystemTestCase
|
4
|
+
setup do
|
5
|
+
@<%= singular_table_name %> = <%= table_name %>(:lazaro_nixon)
|
6
|
+
end
|
7
|
+
|
8
|
+
test "signing in" do
|
9
|
+
visit sign_in_url
|
10
|
+
fill_in "Email", with: @<%= singular_table_name %>.email
|
11
|
+
fill_in "Password", with: "secret123"
|
12
|
+
click_on "Sign in"
|
13
|
+
|
14
|
+
assert_text "Signed in successfully"
|
15
|
+
end
|
16
|
+
|
17
|
+
test "signing out" do
|
18
|
+
sign_in_as @<%= singular_table_name %>
|
19
|
+
|
20
|
+
click_on "Log out"
|
21
|
+
assert_text "Signed out successfully"
|
22
|
+
end
|
23
|
+
|
24
|
+
def sign_in_as(<%= singular_table_name %>)
|
25
|
+
visit sign_in_url
|
26
|
+
fill_in :email, with: <%= singular_table_name %>.email
|
27
|
+
fill_in :password, with: "secret123"
|
28
|
+
click_on "Sign in"
|
29
|
+
|
30
|
+
return <%= singular_table_name %>
|
31
|
+
end
|
32
|
+
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: 0.0.
|
4
|
+
version: 0.0.23
|
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-
|
11
|
+
date: 2022-02-21 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|
@@ -31,36 +31,54 @@ 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
|
35
|
-
- lib/generators/authentication/templates/controllers/api/emails_controller.rb.tt
|
36
|
-
- lib/generators/authentication/templates/controllers/api/password_resets_controller.rb.tt
|
37
|
-
- lib/generators/authentication/templates/controllers/api/passwords_controller.rb.tt
|
38
|
-
- lib/generators/authentication/templates/controllers/api/registrations_controller.rb.tt
|
39
|
-
- lib/generators/authentication/templates/controllers/api/sessions_controller.rb.tt
|
40
|
-
- lib/generators/authentication/templates/controllers/html/cancellations_controller.rb.tt
|
41
|
-
- lib/generators/authentication/templates/controllers/html/emails_controller.rb.tt
|
42
|
-
- lib/generators/authentication/templates/controllers/html/password_resets_controller.rb.tt
|
43
|
-
- lib/generators/authentication/templates/controllers/html/passwords_controller.rb.tt
|
44
|
-
- lib/generators/authentication/templates/controllers/html/registrations_controller.rb.tt
|
45
|
-
- lib/generators/authentication/templates/controllers/html/sessions_controller.rb.tt
|
46
|
-
- lib/generators/authentication/templates/mailers/email_mailer.rb.tt
|
47
|
-
- lib/generators/authentication/templates/mailers/password_mailer.rb.tt
|
48
|
-
- lib/generators/authentication/templates/
|
49
|
-
- lib/generators/authentication/templates/models/
|
50
|
-
- lib/generators/authentication/templates/
|
51
|
-
- lib/generators/authentication/templates/views/
|
52
|
-
- lib/generators/authentication/templates/views/email_mailer/changed.
|
53
|
-
- lib/generators/authentication/templates/views/
|
54
|
-
- lib/generators/authentication/templates/views/
|
55
|
-
- lib/generators/authentication/templates/views/password_mailer/changed.
|
56
|
-
- lib/generators/authentication/templates/views/password_mailer/
|
57
|
-
- lib/generators/authentication/templates/views/password_mailer/reset.
|
58
|
-
- lib/generators/authentication/templates/views/
|
59
|
-
- lib/generators/authentication/templates/views/password_resets/
|
60
|
-
- lib/generators/authentication/templates/views/
|
61
|
-
- lib/generators/authentication/templates/views/
|
62
|
-
- lib/generators/authentication/templates/views/
|
63
|
-
- lib/generators/authentication/templates/
|
34
|
+
- lib/generators/authentication/templates/app/controllers/api/cancellations_controller.rb.tt
|
35
|
+
- lib/generators/authentication/templates/app/controllers/api/emails_controller.rb.tt
|
36
|
+
- lib/generators/authentication/templates/app/controllers/api/password_resets_controller.rb.tt
|
37
|
+
- lib/generators/authentication/templates/app/controllers/api/passwords_controller.rb.tt
|
38
|
+
- lib/generators/authentication/templates/app/controllers/api/registrations_controller.rb.tt
|
39
|
+
- lib/generators/authentication/templates/app/controllers/api/sessions_controller.rb.tt
|
40
|
+
- lib/generators/authentication/templates/app/controllers/html/cancellations_controller.rb.tt
|
41
|
+
- lib/generators/authentication/templates/app/controllers/html/emails_controller.rb.tt
|
42
|
+
- lib/generators/authentication/templates/app/controllers/html/password_resets_controller.rb.tt
|
43
|
+
- lib/generators/authentication/templates/app/controllers/html/passwords_controller.rb.tt
|
44
|
+
- lib/generators/authentication/templates/app/controllers/html/registrations_controller.rb.tt
|
45
|
+
- lib/generators/authentication/templates/app/controllers/html/sessions_controller.rb.tt
|
46
|
+
- lib/generators/authentication/templates/app/mailers/email_mailer.rb.tt
|
47
|
+
- lib/generators/authentication/templates/app/mailers/password_mailer.rb.tt
|
48
|
+
- lib/generators/authentication/templates/app/models/current.rb.tt
|
49
|
+
- lib/generators/authentication/templates/app/models/model.rb.tt
|
50
|
+
- lib/generators/authentication/templates/app/views/cancellations/new.html.erb.tt
|
51
|
+
- lib/generators/authentication/templates/app/views/email_mailer/changed.html.erb.tt
|
52
|
+
- lib/generators/authentication/templates/app/views/email_mailer/changed.text.erb.tt
|
53
|
+
- lib/generators/authentication/templates/app/views/emails/edit.html.erb.tt
|
54
|
+
- lib/generators/authentication/templates/app/views/password_mailer/changed.html.erb.tt
|
55
|
+
- lib/generators/authentication/templates/app/views/password_mailer/changed.text.erb.tt
|
56
|
+
- lib/generators/authentication/templates/app/views/password_mailer/reset.html.erb.tt
|
57
|
+
- lib/generators/authentication/templates/app/views/password_mailer/reset.text.erb.tt
|
58
|
+
- lib/generators/authentication/templates/app/views/password_resets/edit.html.erb.tt
|
59
|
+
- lib/generators/authentication/templates/app/views/password_resets/new.html.erb.tt
|
60
|
+
- lib/generators/authentication/templates/app/views/passwords/edit.html.erb.tt
|
61
|
+
- lib/generators/authentication/templates/app/views/registrations/new.html.erb.tt
|
62
|
+
- lib/generators/authentication/templates/app/views/sessions/new.html.erb.tt
|
63
|
+
- lib/generators/authentication/templates/test_unit/controllers/api/cancellations_controller_test.rb.tt
|
64
|
+
- lib/generators/authentication/templates/test_unit/controllers/api/emails_controller_test.rb.tt
|
65
|
+
- lib/generators/authentication/templates/test_unit/controllers/api/password_resets_controller_test.rb.tt
|
66
|
+
- lib/generators/authentication/templates/test_unit/controllers/api/passwords_controller_test.rb.tt
|
67
|
+
- lib/generators/authentication/templates/test_unit/controllers/api/registrations_controller_test.rb.tt
|
68
|
+
- lib/generators/authentication/templates/test_unit/controllers/api/sessions_controller_test.rb.tt
|
69
|
+
- lib/generators/authentication/templates/test_unit/controllers/html/cancellations_controller_test.rb.tt
|
70
|
+
- lib/generators/authentication/templates/test_unit/controllers/html/emails_controller_test.rb.tt
|
71
|
+
- lib/generators/authentication/templates/test_unit/controllers/html/password_resets_controller_test.rb.tt
|
72
|
+
- lib/generators/authentication/templates/test_unit/controllers/html/passwords_controller_test.rb.tt
|
73
|
+
- lib/generators/authentication/templates/test_unit/controllers/html/registrations_controller_test.rb.tt
|
74
|
+
- lib/generators/authentication/templates/test_unit/controllers/html/sessions_controller_test.rb.tt
|
75
|
+
- lib/generators/authentication/templates/test_unit/fixtures.yml.tt
|
76
|
+
- lib/generators/authentication/templates/test_unit/system/cancellations_test.rb.tt
|
77
|
+
- lib/generators/authentication/templates/test_unit/system/emails_test.rb.tt
|
78
|
+
- lib/generators/authentication/templates/test_unit/system/password_resets_test.rb.tt
|
79
|
+
- lib/generators/authentication/templates/test_unit/system/passwords_test.rb.tt
|
80
|
+
- lib/generators/authentication/templates/test_unit/system/registrations_test.rb.tt
|
81
|
+
- lib/generators/authentication/templates/test_unit/system/sessions_test.rb.tt
|
64
82
|
homepage: https://github.com/lazaronixon/authentication-zero
|
65
83
|
licenses:
|
66
84
|
- MIT
|
@@ -1,14 +0,0 @@
|
|
1
|
-
class <%= migration_class_name %> < ActiveRecord::Migration[<%= ActiveRecord::Migration.current_version %>]
|
2
|
-
def change
|
3
|
-
create_table :<%= table_name %> do |t|
|
4
|
-
t.string :email, null: false
|
5
|
-
t.string :password_digest, null: false
|
6
|
-
t.string :session_token, null: false
|
7
|
-
|
8
|
-
t.timestamps
|
9
|
-
end
|
10
|
-
|
11
|
-
add_index :<%= table_name %>, :email, unique: true
|
12
|
-
add_index :<%= table_name %>, :session_token, unique: true
|
13
|
-
end
|
14
|
-
end
|