authentication-zero 2.3.3 → 2.3.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/authentication_zero/version.rb +1 -1
- data/lib/generators/authentication/authentication_generator.rb +2 -2
- data/lib/generators/authentication/templates/controllers/api/password_resets_controller.rb.tt +2 -2
- data/lib/generators/authentication/templates/controllers/api/registrations_controller.rb.tt +4 -4
- data/lib/generators/authentication/templates/controllers/api/sessions_controller.rb.tt +3 -3
- data/lib/generators/authentication/templates/controllers/html/password_resets_controller.rb.tt +2 -2
- data/lib/generators/authentication/templates/controllers/html/registrations_controller.rb.tt +3 -3
- data/lib/generators/authentication/templates/controllers/html/sessions_controller.rb.tt +2 -2
- data/lib/generators/authentication/templates/erb/identity_mailer/password_reset_provision.html.erb.tt +1 -1
- data/lib/generators/authentication/templates/erb/identity_mailer/password_reset_provision.text.erb.tt +1 -1
- data/lib/generators/authentication/templates/mailers/identity_mailer.rb.tt +2 -2
- data/lib/generators/authentication/templates/migrations/create_sessions_migration.rb.tt +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3cd20da7b0f56b6c19dcc3133bd3423222705fd77b64b6754284b2d0a34b795d
|
4
|
+
data.tar.gz: a4fecf9bdff5dc659b584326323ac6b53840d4bc9e0e0096f957d68d34ce521b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9b16ae0a95f453247ea61761bd50bac1abb196980ec8ec56cae879e58239b3f80ffcbb43cde1de81ac4bd50efecaaada6416890a9a04090c3c558c3ffa28870d
|
7
|
+
data.tar.gz: 4563fc71ef94b056bd823dca4dee733d0a337796b995d886e9eeca5cd82706deb43e108857dd70e1bedf1b29a67c0eb1dd08ef2f9fc231a1c0ef51f3c74f17e8
|
data/Gemfile.lock
CHANGED
@@ -55,7 +55,7 @@ class AuthenticationGenerator < Rails::Generators::NamedBase
|
|
55
55
|
end
|
56
56
|
|
57
57
|
def require_sudo
|
58
|
-
if
|
58
|
+
if Current.session.sudo_at < 30.minutes.ago
|
59
59
|
render json: { error: "Enter your password to continue" }, status: :forbidden
|
60
60
|
end
|
61
61
|
end
|
@@ -73,7 +73,7 @@ class AuthenticationGenerator < Rails::Generators::NamedBase
|
|
73
73
|
end
|
74
74
|
|
75
75
|
def require_sudo
|
76
|
-
if
|
76
|
+
if Current.session.sudo_at < 30.minutes.ago
|
77
77
|
redirect_to new_sudo_path(proceed_to_url: request.url)
|
78
78
|
end
|
79
79
|
end
|
data/lib/generators/authentication/templates/controllers/api/password_resets_controller.rb.tt
CHANGED
@@ -4,8 +4,8 @@ class PasswordResetsController < ApplicationController
|
|
4
4
|
before_action :set_<%= singular_table_name %>, only: :update
|
5
5
|
|
6
6
|
def create
|
7
|
-
if
|
8
|
-
IdentityMailer.with(<%= singular_table_name %>:
|
7
|
+
if @<%= singular_table_name %> = <%= class_name %>.find_by(email: params[:email], verified: true)
|
8
|
+
IdentityMailer.with(<%= singular_table_name %>: @<%= singular_table_name %>).password_reset_provision.deliver_later
|
9
9
|
else
|
10
10
|
render json: { error: "You can't reset your password until you verify your email" }, status: :not_found
|
11
11
|
end
|
@@ -2,12 +2,12 @@ class RegistrationsController < ApplicationController
|
|
2
2
|
skip_before_action :authenticate, only: :create
|
3
3
|
|
4
4
|
def create
|
5
|
-
|
5
|
+
@<%= singular_table_name %> = <%= class_name %>.new(<%= "#{singular_table_name}_params" %>)
|
6
6
|
|
7
|
-
if
|
8
|
-
render json:
|
7
|
+
if @<%= singular_table_name %>.save
|
8
|
+
render json: @<%= singular_table_name %>, status: :created
|
9
9
|
else
|
10
|
-
render json:
|
10
|
+
render json: @<%= singular_table_name %>.errors, status: :unprocessable_entity
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
@@ -15,10 +15,10 @@ 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!(session_params)
|
19
|
-
response.set_header("X-Session-Token", session.signed_id)
|
18
|
+
@session = <%= singular_table_name %>.sessions.create!(session_params)
|
19
|
+
response.set_header("X-Session-Token", @session.signed_id)
|
20
20
|
|
21
|
-
render json: session, status: :created
|
21
|
+
render json: @session, status: :created
|
22
22
|
else
|
23
23
|
render json: { error: "That email or password is incorrect" }, status: :unauthorized
|
24
24
|
end
|
data/lib/generators/authentication/templates/controllers/html/password_resets_controller.rb.tt
CHANGED
@@ -10,8 +10,8 @@ class PasswordResetsController < ApplicationController
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def create
|
13
|
-
if
|
14
|
-
IdentityMailer.with(<%= singular_table_name %>:
|
13
|
+
if @<%= singular_table_name %> = <%= class_name %>.find_by(email: params[:email], verified: true)
|
14
|
+
IdentityMailer.with(<%= singular_table_name %>: @<%= singular_table_name %>).password_reset_provision.deliver_later
|
15
15
|
redirect_to sign_in_path, notice: "Check your email for reset instructions"
|
16
16
|
else
|
17
17
|
redirect_to new_password_reset_path, alert: "You can't reset your password until you verify your email"
|
data/lib/generators/authentication/templates/controllers/html/registrations_controller.rb.tt
CHANGED
@@ -6,10 +6,10 @@ class RegistrationsController < ApplicationController
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def create
|
9
|
-
|
9
|
+
@<%= singular_table_name %> = <%= class_name %>.new(<%= "#{singular_table_name}_params" %>)
|
10
10
|
|
11
|
-
if
|
12
|
-
session =
|
11
|
+
if @<%= singular_table_name %>.save
|
12
|
+
session = @<%= singular_table_name %>.sessions.create!(session_params)
|
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"
|
@@ -15,8 +15,8 @@ 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!(session_params)
|
19
|
-
cookies.signed.permanent[:session_token] = { value: session.id, httponly: true }
|
18
|
+
@session = <%= singular_table_name %>.sessions.create!(session_params)
|
19
|
+
cookies.signed.permanent[:session_token] = { value: @session.id, httponly: true }
|
20
20
|
|
21
21
|
redirect_to root_path, notice: "Signed in successfully"
|
22
22
|
else
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<p>Hey there,</p>
|
2
2
|
|
3
|
-
<p>Can't remember your password for <strong><%%=
|
3
|
+
<p>Can't remember your password for <strong><%%= @<%= singular_table_name %>.email %></strong>? That's OK, it happens. Just hit the link below to set a new one.</p>
|
4
4
|
|
5
5
|
<p><%%= link_to "Reset my password", edit_password_reset_url(token: @signed_id) %></p>
|
6
6
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Hey there,
|
2
2
|
|
3
|
-
Can't remember your password for <%%=
|
3
|
+
Can't remember your password for <%%= @<%= singular_table_name %>.email %>? That's OK, it happens. Just hit the link below to set a new one.
|
4
4
|
|
5
5
|
[Reset my password]<%%= edit_password_reset_url(token: @signed_id) %>
|
6
6
|
|
@@ -1,14 +1,14 @@
|
|
1
1
|
class IdentityMailer < ApplicationMailer
|
2
2
|
def password_reset_provision
|
3
3
|
@<%= singular_table_name %> = params[:<%= singular_table_name %>]
|
4
|
-
@signed_id =
|
4
|
+
@signed_id = @<%= singular_table_name %>.signed_id(purpose: :password_reset, expires_in: 20.minutes)
|
5
5
|
|
6
6
|
mail to: @<%= singular_table_name %>.email, subject: "Reset your password"
|
7
7
|
end
|
8
8
|
|
9
9
|
def email_verify_confirmation
|
10
10
|
@<%= singular_table_name %> = params[:<%= singular_table_name %>]
|
11
|
-
@signed_id =
|
11
|
+
@signed_id = @<%= singular_table_name %>.signed_id(purpose: @<%= singular_table_name %>.email, expires_in: 3.days)
|
12
12
|
|
13
13
|
mail to: @<%= singular_table_name %>.email, subject: "Verify your email"
|
14
14
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
class <%= migration_class_name %> < ActiveRecord::Migration[<%= ActiveRecord::Migration.current_version %>]
|
2
2
|
def change
|
3
3
|
create_table :sessions do |t|
|
4
|
-
t.references
|
4
|
+
t.references :<%= singular_table_name %>, null: false, foreign_key: true
|
5
5
|
|
6
6
|
t.string :user_agent, null: false
|
7
7
|
t.string :ip_address, null: false
|
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: 2.3.
|
4
|
+
version: 2.3.6
|
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-27 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|