authentication-zero 2.8.4 → 2.9.0
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/CHANGELOG.md +4 -0
- data/Gemfile.lock +1 -1
- data/README.md +1 -0
- data/lib/authentication_zero/version.rb +1 -1
- data/lib/generators/authentication/authentication_generator.rb +49 -19
- data/lib/generators/authentication/templates/controllers/api/authentications/events_controller.rb.tt +5 -0
- data/lib/generators/authentication/templates/controllers/api/sessions_controller.rb.tt +1 -5
- data/lib/generators/authentication/templates/controllers/html/authentications/events_controller.rb.tt +5 -0
- data/lib/generators/authentication/templates/controllers/html/registrations_controller.rb.tt +1 -5
- data/lib/generators/authentication/templates/controllers/{omniauth_controller.rb.tt → html/sessions/omniauth_controller.rb.tt} +1 -5
- data/lib/generators/authentication/templates/controllers/html/sessions_controller.rb.tt +1 -5
- data/lib/generators/authentication/templates/erb/authentications/events/index.html.erb +33 -0
- data/lib/generators/authentication/templates/migrations/create_events_migration.rb.tt +12 -0
- data/lib/generators/authentication/templates/migrations/create_sessions_migration.rb.tt +2 -2
- data/lib/generators/authentication/templates/migrations/create_table_migration.rb.tt +1 -1
- data/lib/generators/authentication/templates/models/current.rb.tt +1 -0
- data/lib/generators/authentication/templates/models/event.rb.tt +8 -0
- data/lib/generators/authentication/templates/models/model.rb.tt +16 -4
- data/lib/generators/authentication/templates/models/session.rb.tt +15 -0
- data/lib/generators/authentication/templates/test_unit/controllers/api/identity/email_verifications_controller_test.rb.tt +1 -1
- data/lib/generators/authentication/templates/test_unit/controllers/api/identity/emails_controller_test.rb.tt +1 -1
- data/lib/generators/authentication/templates/test_unit/controllers/api/passwords_controller_test.rb.tt +1 -1
- data/lib/generators/authentication/templates/test_unit/controllers/api/sessions/sudos_controller_test.rb.tt +1 -1
- data/lib/generators/authentication/templates/test_unit/controllers/api/sessions_controller_test.rb.tt +3 -3
- data/lib/generators/authentication/templates/test_unit/controllers/html/identity/email_verifications_controller_test.rb.tt +1 -1
- data/lib/generators/authentication/templates/test_unit/controllers/html/identity/emails_controller_test.rb.tt +1 -1
- data/lib/generators/authentication/templates/test_unit/controllers/html/passwords_controller_test.rb.tt +1 -1
- data/lib/generators/authentication/templates/test_unit/controllers/html/registrations_controller_test.rb.tt +1 -1
- data/lib/generators/authentication/templates/test_unit/controllers/html/sessions/sudos_controller_test.rb.tt +1 -1
- data/lib/generators/authentication/templates/test_unit/controllers/html/sessions_controller_test.rb.tt +3 -3
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 17c277204408ebec113d5e006bec8407d237756e4f86c67dae7a0e01c4a1c0de
|
4
|
+
data.tar.gz: 87c2e57c9035847f84abc12b1c4f0a7350c4a010cd9c6fc8442d9c229b646af7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2bb208d31c2d4a5d9af479253f39db98e5c2182796a74debb06aeadcdec22547abd29b90a6f440cca29405ef2110937d2a5185085f3f321acd705d409ec65b16
|
7
|
+
data.tar.gz: f36f9a8791f1bcb6b821c69694b416481aa3811383f55027362e9a92cd3e1aea11436aab998b50eea620b089a84ee05fa88725732fa087bf570794c105085ba6
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -20,6 +20,7 @@ The purpose of authentication zero is to generate a pre-built authentication sys
|
|
20
20
|
- Send e-mail confirmation when your email has been changed
|
21
21
|
- Send e-mail notification when someone has logged into your account
|
22
22
|
- Manage multiple sessions & devices
|
23
|
+
- Activity log (--trackable)
|
23
24
|
- Log out
|
24
25
|
|
25
26
|
## Security and best practices
|
@@ -8,6 +8,7 @@ class AuthenticationGenerator < Rails::Generators::NamedBase
|
|
8
8
|
class_option :lockable, type: :boolean, desc: "Add password reset locking"
|
9
9
|
class_option :ratelimit, type: :boolean, desc: "Add request rate limiting"
|
10
10
|
class_option :omniauthable, type: :boolean, desc: "Add social login support"
|
11
|
+
class_option :trackable, type: :boolean, desc: "Add activity log support"
|
11
12
|
|
12
13
|
source_root File.expand_path("templates", __dir__)
|
13
14
|
|
@@ -47,6 +48,7 @@ class AuthenticationGenerator < Rails::Generators::NamedBase
|
|
47
48
|
def create_migrations
|
48
49
|
migration_template "migrations/create_table_migration.rb", "#{db_migrate_path}/create_#{table_name}.rb"
|
49
50
|
migration_template "migrations/create_sessions_migration.rb", "#{db_migrate_path}/create_sessions.rb"
|
51
|
+
migration_template "migrations/create_events_migration.rb", "#{db_migrate_path}/create_events.rb" if options.trackable?
|
50
52
|
end
|
51
53
|
|
52
54
|
def create_models
|
@@ -54,6 +56,7 @@ class AuthenticationGenerator < Rails::Generators::NamedBase
|
|
54
56
|
template "models/session.rb", "app/models/session.rb"
|
55
57
|
template "models/current.rb", "app/models/current.rb"
|
56
58
|
template "models/locking.rb", "app/models/locking.rb" if options.lockable?
|
59
|
+
template "models/event.rb", "app/models/event.rb" if options.trackable?
|
57
60
|
end
|
58
61
|
|
59
62
|
def create_fixture_file
|
@@ -64,39 +67,53 @@ class AuthenticationGenerator < Rails::Generators::NamedBase
|
|
64
67
|
api_code = <<~CODE
|
65
68
|
include ActionController::HttpAuthentication::Token::ControllerMethods
|
66
69
|
|
70
|
+
before_action :set_current_request_details
|
67
71
|
before_action :authenticate
|
68
72
|
|
69
|
-
def authenticate
|
70
|
-
if session = authenticate_with_http_token { |token, _| Session.find_signed(token) }
|
71
|
-
Current.session = session
|
72
|
-
else
|
73
|
-
request_http_token_authentication
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
73
|
def require_sudo
|
78
74
|
if Current.session.sudo_at < 30.minutes.ago
|
79
75
|
render json: { error: "Enter your password to continue" }, status: :forbidden
|
80
76
|
end
|
81
77
|
end
|
78
|
+
|
79
|
+
private
|
80
|
+
def authenticate
|
81
|
+
if session = authenticate_with_http_token { |token, _| Session.find_signed(token) }
|
82
|
+
Current.session = session
|
83
|
+
else
|
84
|
+
request_http_token_authentication
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
def set_current_request_details
|
89
|
+
Current.user_agent = request.user_agent
|
90
|
+
Current.ip_address = request.ip
|
91
|
+
end
|
82
92
|
CODE
|
83
93
|
|
84
94
|
html_code = <<~CODE
|
95
|
+
before_action :set_current_request_details
|
85
96
|
before_action :authenticate
|
86
97
|
|
87
|
-
def authenticate
|
88
|
-
if session = Session.find_by_id(cookies.signed[:session_token])
|
89
|
-
Current.session = session
|
90
|
-
else
|
91
|
-
redirect_to sign_in_path
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
98
|
def require_sudo
|
96
99
|
if Current.session.sudo_at < 30.minutes.ago
|
97
100
|
redirect_to new_sessions_sudo_path(proceed_to_url: request.url)
|
98
101
|
end
|
99
102
|
end
|
103
|
+
|
104
|
+
private
|
105
|
+
def authenticate
|
106
|
+
if session = Session.find_by_id(cookies.signed[:session_token])
|
107
|
+
Current.session = session
|
108
|
+
else
|
109
|
+
redirect_to sign_in_path
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
def set_current_request_details
|
114
|
+
Current.user_agent = request.user_agent
|
115
|
+
Current.ip_address = request.ip
|
116
|
+
end
|
100
117
|
CODE
|
101
118
|
|
102
119
|
inject_code = options.api? ? api_code : html_code
|
@@ -104,8 +121,13 @@ class AuthenticationGenerator < Rails::Generators::NamedBase
|
|
104
121
|
end
|
105
122
|
|
106
123
|
def create_controllers
|
107
|
-
directory "controllers/#{format_folder}", "app/controllers"
|
108
|
-
template "controllers/
|
124
|
+
directory "controllers/#{format_folder}/identity", "app/controllers/identity"
|
125
|
+
template "controllers/#{format_folder}/passwords_controller.rb", "app/controllers/passwords_controller.rb"
|
126
|
+
template "controllers/#{format_folder}/registrations_controller.rb", "app/controllers/registrations_controller.rb"
|
127
|
+
template "controllers/#{format_folder}/sessions_controller.rb", "app/controllers/sessions_controller.rb"
|
128
|
+
template "controllers/#{format_folder}/sessions/sudos_controller.rb", "app/controllers/sessions/sudos_controller.rb"
|
129
|
+
template "controllers/#{format_folder}/sessions/omniauth_controller.rb", "app/controllers/sessions/omniauth_controller.rb" if omniauthable?
|
130
|
+
template "controllers/#{format_folder}/authentications/events_controller.rb", "app/controllers/authentications/events_controller.rb" if options.trackable?
|
109
131
|
end
|
110
132
|
|
111
133
|
def create_views
|
@@ -113,7 +135,11 @@ class AuthenticationGenerator < Rails::Generators::NamedBase
|
|
113
135
|
directory "erb/identity_mailer", "app/views/identity_mailer"
|
114
136
|
directory "erb/session_mailer", "app/views/session_mailer"
|
115
137
|
else
|
116
|
-
directory "erb", "app/views"
|
138
|
+
directory "erb/identity", "app/views/identity"
|
139
|
+
directory "erb/passwords", "app/views/passwords"
|
140
|
+
directory "erb/registrations", "app/views/registrations"
|
141
|
+
directory "erb/sessions", "app/views/sessions"
|
142
|
+
directory "erb/authentications/events", "app/views/authentications/events" if options.trackable?
|
117
143
|
end
|
118
144
|
end
|
119
145
|
|
@@ -128,6 +154,10 @@ class AuthenticationGenerator < Rails::Generators::NamedBase
|
|
128
154
|
route "get '/auth/failure', to: 'sessions/omniauth#failure'"
|
129
155
|
end
|
130
156
|
|
157
|
+
if options.trackable?
|
158
|
+
route "resources :events, only: :index", namespace: :authentications
|
159
|
+
end
|
160
|
+
|
131
161
|
route "resource :password_reset, only: [:new, :edit, :create, :update]", namespace: :identity
|
132
162
|
route "resource :email_verification, only: [:edit, :create]", namespace: :identity
|
133
163
|
route "resource :email, only: [:edit, :update]", namespace: :identity
|
@@ -15,7 +15,7 @@ class SessionsController < ApplicationController
|
|
15
15
|
<%= singular_table_name %> = <%= class_name %>.find_by(email: params[:email])
|
16
16
|
|
17
17
|
if <%= singular_table_name %> && <%= singular_table_name %>.authenticate(params[:password])
|
18
|
-
@session = <%= singular_table_name %>.sessions.create!
|
18
|
+
@session = <%= singular_table_name %>.sessions.create!
|
19
19
|
response.set_header("X-Session-Token", @session.signed_id)
|
20
20
|
|
21
21
|
render json: @session, status: :created
|
@@ -32,8 +32,4 @@ class SessionsController < ApplicationController
|
|
32
32
|
def set_session
|
33
33
|
@session = Current.<%= singular_table_name %>.sessions.find(params[:id])
|
34
34
|
end
|
35
|
-
|
36
|
-
def session_params
|
37
|
-
{ user_agent: request.user_agent, ip_address: request.remote_ip, sudo_at: Time.current }
|
38
|
-
end
|
39
35
|
end
|
data/lib/generators/authentication/templates/controllers/html/registrations_controller.rb.tt
CHANGED
@@ -9,7 +9,7 @@ class RegistrationsController < ApplicationController
|
|
9
9
|
@<%= singular_table_name %> = <%= class_name %>.new(<%= "#{singular_table_name}_params" %>)
|
10
10
|
|
11
11
|
if @<%= singular_table_name %>.save
|
12
|
-
session = @<%= singular_table_name %>.sessions.create!
|
12
|
+
session = @<%= singular_table_name %>.sessions.create!
|
13
13
|
cookies.signed.permanent[:session_token] = { value: session.id, httponly: true }
|
14
14
|
|
15
15
|
redirect_to root_path, notice: "Welcome! You have signed up successfully"
|
@@ -22,8 +22,4 @@ class RegistrationsController < ApplicationController
|
|
22
22
|
def <%= "#{singular_table_name}_params" %>
|
23
23
|
params.permit(:email, :password, :password_confirmation)
|
24
24
|
end
|
25
|
-
|
26
|
-
def session_params
|
27
|
-
{ user_agent: request.user_agent, ip_address: request.remote_ip, sudo_at: Time.current }
|
28
|
-
end
|
29
25
|
end
|
@@ -6,7 +6,7 @@ class Sessions::OmniauthController < ApplicationController
|
|
6
6
|
@<%= singular_table_name %> = <%= class_name %>.where(omniauth_params).first_or_initialize(<%= "#{singular_table_name}_params" %>)
|
7
7
|
|
8
8
|
if @<%= singular_table_name %>.save
|
9
|
-
session = @<%= singular_table_name %>.sessions.create!
|
9
|
+
session = @<%= singular_table_name %>.sessions.create!
|
10
10
|
cookies.signed.permanent[:session_token] = { value: session.id, httponly: true }
|
11
11
|
|
12
12
|
redirect_to root_path, notice: "Signed in successfully"
|
@@ -28,10 +28,6 @@ class Sessions::OmniauthController < ApplicationController
|
|
28
28
|
{ email: omniauth.info.email, password: SecureRandom::base58, verified: true }
|
29
29
|
end
|
30
30
|
|
31
|
-
def session_params
|
32
|
-
{ user_agent: request.user_agent, ip_address: request.remote_ip, sudo_at: Time.current }
|
33
|
-
end
|
34
|
-
|
35
31
|
def omniauth
|
36
32
|
request.env["omniauth.auth"]
|
37
33
|
end
|
@@ -15,7 +15,7 @@ class SessionsController < ApplicationController
|
|
15
15
|
<%= singular_table_name %> = <%= class_name %>.find_by(email: params[:email])
|
16
16
|
|
17
17
|
if <%= singular_table_name %> && <%= singular_table_name %>.authenticate(params[:password])
|
18
|
-
@session = <%= singular_table_name %>.sessions.create!
|
18
|
+
@session = <%= singular_table_name %>.sessions.create!
|
19
19
|
cookies.signed.permanent[:session_token] = { value: @session.id, httponly: true }
|
20
20
|
|
21
21
|
redirect_to root_path, notice: "Signed in successfully"
|
@@ -32,8 +32,4 @@ class SessionsController < ApplicationController
|
|
32
32
|
def set_session
|
33
33
|
@session = Current.<%= singular_table_name %>.sessions.find(params[:id])
|
34
34
|
end
|
35
|
-
|
36
|
-
def session_params
|
37
|
-
{ user_agent: request.user_agent, ip_address: request.remote_ip, sudo_at: Time.current }
|
38
|
-
end
|
39
35
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
<h1>Activity Log</h1>
|
2
|
+
|
3
|
+
<div id="sessions">
|
4
|
+
<% @events.each do |event| %>
|
5
|
+
<div id="<%= dom_id event %>">
|
6
|
+
<p>
|
7
|
+
<strong>User Agent:</strong>
|
8
|
+
<%= event.user_agent %>
|
9
|
+
</p>
|
10
|
+
|
11
|
+
<p>
|
12
|
+
<strong>Action:</strong>
|
13
|
+
<%= event.action %>
|
14
|
+
</p>
|
15
|
+
|
16
|
+
<p>
|
17
|
+
<strong>Ip Address:</strong>
|
18
|
+
<%= event.ip_address %>
|
19
|
+
</p>
|
20
|
+
|
21
|
+
<p>
|
22
|
+
<strong>Created at:</strong>
|
23
|
+
<%= event.created_at %>
|
24
|
+
</p>
|
25
|
+
</div>
|
26
|
+
<% end %>
|
27
|
+
</div>
|
28
|
+
|
29
|
+
<br>
|
30
|
+
|
31
|
+
<div>
|
32
|
+
<%= link_to "Back", root_path %>
|
33
|
+
</div>
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class <%= migration_class_name %> < ActiveRecord::Migration[<%= ActiveRecord::Migration.current_version %>]
|
2
|
+
def change
|
3
|
+
create_table :events do |t|
|
4
|
+
t.references :<%= singular_table_name %>, null: false, foreign_key: true
|
5
|
+
t.string :action, null: false
|
6
|
+
t.string :user_agent
|
7
|
+
t.string :ip_address
|
8
|
+
|
9
|
+
t.timestamps
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -3,8 +3,8 @@ class <%= migration_class_name %> < ActiveRecord::Migration[<%= ActiveRecord::Mi
|
|
3
3
|
create_table :sessions do |t|
|
4
4
|
t.references :<%= singular_table_name %>, null: false, foreign_key: true
|
5
5
|
|
6
|
-
t.string :user_agent
|
7
|
-
t.string :ip_address
|
6
|
+
t.string :user_agent
|
7
|
+
t.string :ip_address
|
8
8
|
|
9
9
|
t.datetime :sudo_at, null: false
|
10
10
|
|
@@ -2,6 +2,9 @@ class <%= class_name %> < ApplicationRecord
|
|
2
2
|
has_secure_password
|
3
3
|
|
4
4
|
has_many :sessions, dependent: :destroy
|
5
|
+
<% if options.trackable? -%>
|
6
|
+
has_many :events, dependent: :destroy
|
7
|
+
<% end -%>
|
5
8
|
|
6
9
|
validates :email, presence: true, uniqueness: true
|
7
10
|
validates_format_of :email, with: /\A[^@\s]+@[^@\s]+\z/
|
@@ -24,11 +27,20 @@ class <%= class_name %> < ApplicationRecord
|
|
24
27
|
sessions.where.not(id: Current.session).destroy_all
|
25
28
|
end
|
26
29
|
|
27
|
-
|
28
|
-
IdentityMailer.with(
|
30
|
+
after_save_commit if: :email_previously_changed? do
|
31
|
+
IdentityMailer.with(user: self).email_verify_confirmation.deliver_later
|
32
|
+
end
|
33
|
+
<% if options.trackable? %>
|
34
|
+
after_save_commit if: :email_previously_changed? do
|
35
|
+
events.create! action: "email_verification_requested"
|
36
|
+
end
|
37
|
+
|
38
|
+
after_update if: :password_digest_previously_changed? do
|
39
|
+
events.create! action: "password_changed"
|
29
40
|
end
|
30
41
|
|
31
|
-
|
32
|
-
|
42
|
+
after_update if: :verified_previously_changed? do
|
43
|
+
events.create! action: "email_verified" if verified?
|
33
44
|
end
|
45
|
+
<% end -%>
|
34
46
|
end
|
@@ -1,7 +1,22 @@
|
|
1
1
|
class Session < ApplicationRecord
|
2
2
|
belongs_to :<%= singular_table_name %>
|
3
3
|
|
4
|
+
before_create do
|
5
|
+
self.user_agent = Current.user_agent
|
6
|
+
self.ip_address = Current.ip_address
|
7
|
+
self.sudo_at = Time.current
|
8
|
+
end
|
9
|
+
|
4
10
|
after_create_commit do
|
5
11
|
SessionMailer.with(session: self).signed_in_notification.deliver_later
|
6
12
|
end
|
13
|
+
<% if options.trackable? %>
|
14
|
+
after_create do
|
15
|
+
<%= singular_table_name %>.events.create! action: "signed_in"
|
16
|
+
end
|
17
|
+
|
18
|
+
after_destroy do
|
19
|
+
<%= singular_table_name %>.events.create! action: "signed_out"
|
20
|
+
end
|
21
|
+
<% end -%>
|
7
22
|
end
|
@@ -39,6 +39,6 @@ class Identity::EmailVerificationsControllerTest < ActionDispatch::IntegrationTe
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def sign_in_as(<%= singular_table_name %>)
|
42
|
-
post(sign_in_url, params: { email: <%= singular_table_name %>.email, password: "Secret1*3*5*" }
|
42
|
+
post(sign_in_url, params: { email: <%= singular_table_name %>.email, password: "Secret1*3*5*" }); [<%= singular_table_name %>, response.headers["X-Session-Token"]]
|
43
43
|
end
|
44
44
|
end
|
@@ -20,6 +20,6 @@ class Identity::EmailsControllerTest < ActionDispatch::IntegrationTest
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def sign_in_as(<%= singular_table_name %>)
|
23
|
-
post(sign_in_url, params: { email: <%= singular_table_name %>.email, password: "Secret1*3*5*" }
|
23
|
+
post(sign_in_url, params: { email: <%= singular_table_name %>.email, password: "Secret1*3*5*" }); [<%= singular_table_name %>, response.headers["X-Session-Token"]]
|
24
24
|
end
|
25
25
|
end
|
@@ -18,6 +18,6 @@ class PasswordsControllerTest < ActionDispatch::IntegrationTest
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def sign_in_as(<%= singular_table_name %>)
|
21
|
-
post(sign_in_url, params: { email: <%= singular_table_name %>.email, password: "Secret1*3*5*" }
|
21
|
+
post(sign_in_url, params: { email: <%= singular_table_name %>.email, password: "Secret1*3*5*" }); [<%= singular_table_name %>, response.headers["X-Session-Token"]]
|
22
22
|
end
|
23
23
|
end
|
@@ -19,6 +19,6 @@ class Sessions::SudosControllerTest < ActionDispatch::IntegrationTest
|
|
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: "Secret1*3*5*" }
|
22
|
+
post(sign_in_url, params: { email: <%= singular_table_name %>.email, password: "Secret1*3*5*" }); [<%= singular_table_name %>, response.headers["X-Session-Token"]]
|
23
23
|
end
|
24
24
|
end
|
@@ -16,14 +16,14 @@ class SessionsControllerTest < ActionDispatch::IntegrationTest
|
|
16
16
|
end
|
17
17
|
|
18
18
|
test "should sign in" do
|
19
|
-
post sign_in_url, params: { email: @<%= singular_table_name %>.email, password: "Secret1*3*5*" }
|
19
|
+
post sign_in_url, params: { email: @<%= singular_table_name %>.email, password: "Secret1*3*5*" }
|
20
20
|
|
21
21
|
assert_enqueued_email_with SessionMailer, :signed_in_notification, args: { session: @<%= singular_table_name %>.sessions.last }
|
22
22
|
assert_response :created
|
23
23
|
end
|
24
24
|
|
25
25
|
test "should not sign in with wrong credentials" do
|
26
|
-
post sign_in_url, params: { email: @<%= singular_table_name %>.email, password: "SecretWrong1*3" }
|
26
|
+
post sign_in_url, params: { email: @<%= singular_table_name %>.email, password: "SecretWrong1*3" }
|
27
27
|
assert_response :unauthorized
|
28
28
|
end
|
29
29
|
|
@@ -33,6 +33,6 @@ class SessionsControllerTest < ActionDispatch::IntegrationTest
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def sign_in_as(<%= singular_table_name %>)
|
36
|
-
post(sign_in_url, params: { email: <%= singular_table_name %>.email, password: "Secret1*3*5*" }
|
36
|
+
post(sign_in_url, params: { email: <%= singular_table_name %>.email, password: "Secret1*3*5*" }); [<%= singular_table_name %>, response.headers["X-Session-Token"]]
|
37
37
|
end
|
38
38
|
end
|
@@ -39,6 +39,6 @@ class Identity::EmailVerificationsControllerTest < ActionDispatch::IntegrationTe
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def sign_in_as(<%= singular_table_name %>)
|
42
|
-
post(sign_in_url, params: { email: <%= singular_table_name %>.email, password: "Secret1*3*5*" }
|
42
|
+
post(sign_in_url, params: { email: <%= singular_table_name %>.email, password: "Secret1*3*5*" }); <%= singular_table_name %>
|
43
43
|
end
|
44
44
|
end
|
@@ -30,6 +30,6 @@ class Identity::EmailsControllerTest < ActionDispatch::IntegrationTest
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def sign_in_as(<%= singular_table_name %>)
|
33
|
-
post(sign_in_url, params: { email: <%= singular_table_name %>.email, password: "Secret1*3*5*" }
|
33
|
+
post(sign_in_url, params: { email: <%= singular_table_name %>.email, password: "Secret1*3*5*" }); <%= singular_table_name %>
|
34
34
|
end
|
35
35
|
end
|
@@ -23,6 +23,6 @@ class PasswordsControllerTest < ActionDispatch::IntegrationTest
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def sign_in_as(<%= singular_table_name %>)
|
26
|
-
post(sign_in_url, params: { email: <%= singular_table_name %>.email, password: "Secret1*3*5*" }
|
26
|
+
post(sign_in_url, params: { email: <%= singular_table_name %>.email, password: "Secret1*3*5*" }); <%= singular_table_name %>
|
27
27
|
end
|
28
28
|
end
|
@@ -8,7 +8,7 @@ class RegistrationsControllerTest < ActionDispatch::IntegrationTest
|
|
8
8
|
|
9
9
|
test "should sign up" do
|
10
10
|
assert_difference("<%= class_name %>.count") do
|
11
|
-
post sign_up_url, params: { email: "lazaronixon@hey.com", password: "Secret1*3*5*", password_confirmation: "Secret1*3*5*" }
|
11
|
+
post sign_up_url, params: { email: "lazaronixon@hey.com", password: "Secret1*3*5*", password_confirmation: "Secret1*3*5*" }
|
12
12
|
end
|
13
13
|
|
14
14
|
assert_redirected_to root_url
|
@@ -21,6 +21,6 @@ class Sessions::SudosControllerTest < ActionDispatch::IntegrationTest
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def sign_in_as(<%= singular_table_name %>)
|
24
|
-
post(sign_in_url, params: { email: <%= singular_table_name %>.email, password: "Secret1*3*5*" }
|
24
|
+
post(sign_in_url, params: { email: <%= singular_table_name %>.email, password: "Secret1*3*5*" }); [<%= singular_table_name %>, response.headers["X-Session-Token"]]
|
25
25
|
end
|
26
26
|
end
|
@@ -18,7 +18,7 @@ class SessionsControllerTest < ActionDispatch::IntegrationTest
|
|
18
18
|
end
|
19
19
|
|
20
20
|
test "should sign in" do
|
21
|
-
post sign_in_url, params: { email: @<%= singular_table_name %>.email, password: "Secret1*3*5*" }
|
21
|
+
post sign_in_url, params: { email: @<%= singular_table_name %>.email, password: "Secret1*3*5*" }
|
22
22
|
assert_enqueued_email_with SessionMailer, :signed_in_notification, args: { session: @<%= singular_table_name %>.sessions.last }
|
23
23
|
|
24
24
|
assert_redirected_to root_url
|
@@ -28,7 +28,7 @@ class SessionsControllerTest < ActionDispatch::IntegrationTest
|
|
28
28
|
end
|
29
29
|
|
30
30
|
test "should not sign in with wrong credentials" do
|
31
|
-
post sign_in_url, params: { email: @<%= singular_table_name %>.email, password: "SecretWrong1*3" }
|
31
|
+
post sign_in_url, params: { email: @<%= singular_table_name %>.email, password: "SecretWrong1*3" }
|
32
32
|
assert_redirected_to sign_in_url(email_hint: @<%= singular_table_name %>.email)
|
33
33
|
assert_equal "That email or password is incorrect", flash[:alert]
|
34
34
|
|
@@ -47,6 +47,6 @@ class SessionsControllerTest < ActionDispatch::IntegrationTest
|
|
47
47
|
end
|
48
48
|
|
49
49
|
def sign_in_as(<%= singular_table_name %>)
|
50
|
-
post(sign_in_url, params: { email: <%= singular_table_name %>.email, password: "Secret1*3*5*" }
|
50
|
+
post(sign_in_url, params: { email: <%= singular_table_name %>.email, password: "Secret1*3*5*" }); <%= singular_table_name %>
|
51
51
|
end
|
52
52
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: authentication-zero
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nixon
|
@@ -34,6 +34,7 @@ files:
|
|
34
34
|
- lib/generators/authentication/authentication_generator.rb
|
35
35
|
- lib/generators/authentication/templates/config/initializers/omniauth.rb
|
36
36
|
- lib/generators/authentication/templates/config/redis/shared.yml
|
37
|
+
- lib/generators/authentication/templates/controllers/api/authentications/events_controller.rb.tt
|
37
38
|
- lib/generators/authentication/templates/controllers/api/identity/email_verifications_controller.rb.tt
|
38
39
|
- lib/generators/authentication/templates/controllers/api/identity/emails_controller.rb.tt
|
39
40
|
- lib/generators/authentication/templates/controllers/api/identity/password_resets_controller.rb.tt
|
@@ -41,14 +42,16 @@ files:
|
|
41
42
|
- lib/generators/authentication/templates/controllers/api/registrations_controller.rb.tt
|
42
43
|
- lib/generators/authentication/templates/controllers/api/sessions/sudos_controller.rb.tt
|
43
44
|
- lib/generators/authentication/templates/controllers/api/sessions_controller.rb.tt
|
45
|
+
- lib/generators/authentication/templates/controllers/html/authentications/events_controller.rb.tt
|
44
46
|
- lib/generators/authentication/templates/controllers/html/identity/email_verifications_controller.rb.tt
|
45
47
|
- lib/generators/authentication/templates/controllers/html/identity/emails_controller.rb.tt
|
46
48
|
- lib/generators/authentication/templates/controllers/html/identity/password_resets_controller.rb.tt
|
47
49
|
- lib/generators/authentication/templates/controllers/html/passwords_controller.rb.tt
|
48
50
|
- lib/generators/authentication/templates/controllers/html/registrations_controller.rb.tt
|
51
|
+
- lib/generators/authentication/templates/controllers/html/sessions/omniauth_controller.rb.tt
|
49
52
|
- lib/generators/authentication/templates/controllers/html/sessions/sudos_controller.rb.tt
|
50
53
|
- lib/generators/authentication/templates/controllers/html/sessions_controller.rb.tt
|
51
|
-
- lib/generators/authentication/templates/
|
54
|
+
- lib/generators/authentication/templates/erb/authentications/events/index.html.erb
|
52
55
|
- lib/generators/authentication/templates/erb/identity/emails/edit.html.erb.tt
|
53
56
|
- lib/generators/authentication/templates/erb/identity/password_resets/edit.html.erb.tt
|
54
57
|
- lib/generators/authentication/templates/erb/identity/password_resets/new.html.erb.tt
|
@@ -65,9 +68,11 @@ files:
|
|
65
68
|
- lib/generators/authentication/templates/erb/sessions/sudos/new.html.erb.tt
|
66
69
|
- lib/generators/authentication/templates/mailers/identity_mailer.rb.tt
|
67
70
|
- lib/generators/authentication/templates/mailers/session_mailer.rb.tt
|
71
|
+
- lib/generators/authentication/templates/migrations/create_events_migration.rb.tt
|
68
72
|
- lib/generators/authentication/templates/migrations/create_sessions_migration.rb.tt
|
69
73
|
- lib/generators/authentication/templates/migrations/create_table_migration.rb.tt
|
70
74
|
- lib/generators/authentication/templates/models/current.rb.tt
|
75
|
+
- lib/generators/authentication/templates/models/event.rb.tt
|
71
76
|
- lib/generators/authentication/templates/models/locking.rb.tt
|
72
77
|
- lib/generators/authentication/templates/models/model.rb.tt
|
73
78
|
- lib/generators/authentication/templates/models/session.rb.tt
|