authentication-zero 2.3.3 → 2.3.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9b21b7a771364a0d7b04c7e53a5977febf8cdc32cb71bb6c221c1d12ca66d7cb
4
- data.tar.gz: cebe4c241e5286362c3ca64667ec429ba24c13526c4e2dd6830c1bac1e82af06
3
+ metadata.gz: 3cd20da7b0f56b6c19dcc3133bd3423222705fd77b64b6754284b2d0a34b795d
4
+ data.tar.gz: a4fecf9bdff5dc659b584326323ac6b53840d4bc9e0e0096f957d68d34ce521b
5
5
  SHA512:
6
- metadata.gz: fd13b4bbacb750616f8c50fedcd10edf81d97dbeb8e07353ef4f8e3639fcc5920e28ed1b2d23a26c7d109b38fb8e808bfa7d46f5f00708cb7f16b4d121924443
7
- data.tar.gz: 92a2247ccec6a39bcaab61493a774e832e2d8892a9726d40ab574f7b019c8b9c148330582f8e9e2262469434aa2a688d3c6bcf66cda3f90bbc23e71b5a37273e
6
+ metadata.gz: 9b16ae0a95f453247ea61761bd50bac1abb196980ec8ec56cae879e58239b3f80ffcbb43cde1de81ac4bd50efecaaada6416890a9a04090c3c558c3ffa28870d
7
+ data.tar.gz: 4563fc71ef94b056bd823dca4dee733d0a337796b995d886e9eeca5cd82706deb43e108857dd70e1bedf1b29a67c0eb1dd08ef2f9fc231a1c0ef51f3c74f17e8
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- authentication-zero (2.3.3)
4
+ authentication-zero (2.3.6)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -1,3 +1,3 @@
1
1
  module AuthenticationZero
2
- VERSION = "2.3.3"
2
+ VERSION = "2.3.6"
3
3
  end
@@ -55,7 +55,7 @@ class AuthenticationGenerator < Rails::Generators::NamedBase
55
55
  end
56
56
 
57
57
  def require_sudo
58
- if Time.current > 30.minutes.after(Current.session.sudo_at)
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 Time.current > 30.minutes.after(Current.session.sudo_at)
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
@@ -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 <%= 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
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
- <%= singular_table_name %> = <%= class_name %>.new(<%= "#{singular_table_name}_params" %>)
5
+ @<%= singular_table_name %> = <%= class_name %>.new(<%= "#{singular_table_name}_params" %>)
6
6
 
7
- if <%= singular_table_name %>.save
8
- render json: <%= singular_table_name %>, status: :created
7
+ if @<%= singular_table_name %>.save
8
+ render json: @<%= singular_table_name %>, status: :created
9
9
  else
10
- render json: <%= singular_table_name %>.errors, status: :unprocessable_entity
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
@@ -10,8 +10,8 @@ class PasswordResetsController < ApplicationController
10
10
  end
11
11
 
12
12
  def create
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
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"
@@ -6,10 +6,10 @@ class RegistrationsController < ApplicationController
6
6
  end
7
7
 
8
8
  def create
9
- <%= singular_table_name %> = <%= class_name %>.new(<%= "#{singular_table_name}_params" %>)
9
+ @<%= singular_table_name %> = <%= class_name %>.new(<%= "#{singular_table_name}_params" %>)
10
10
 
11
- if <%= singular_table_name %>.save
12
- session = <%= singular_table_name %>.sessions.create!(session_params)
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><%%= @session.<%= singular_table_name %>.email %></strong>? That's OK, it happens. Just hit the link below to set a new one.</p>
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 <%%= @session.<%= singular_table_name %>.email %>? That's OK, it happens. Just hit the link below to set a new one.
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 = params[:<%= singular_table_name %>].signed_id(purpose: :password_reset, expires_in: 20.minutes)
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 = params[:<%= singular_table_name %>].signed_id(purpose: @<%= singular_table_name %>.email, expires_in: 20.minutes)
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 :user, null: false, foreign_key: true
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.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-26 00:00:00.000000000 Z
11
+ date: 2022-02-27 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: