authentication-zero 2.15.1 → 2.15.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d77763ad7dead2a863eda83bfac8f792968850885e267126dfd1b1ea64851c6d
4
- data.tar.gz: b0387c9925290b63802b32b0cddd08bbf0e9ff55c71b5fcb8c87ce684d180a13
3
+ metadata.gz: 672ec873e54822b2b2326c699dd9a0be3ea0034251c38b34c5ef541be69967b6
4
+ data.tar.gz: a4e898e189bb3e20fb2e143378c8a6625d857ff57619592b669de9e076dfc6d1
5
5
  SHA512:
6
- metadata.gz: '0944d14cbacd55436ace47b3665397e20a08603d73e46d25d25f0bdd6fbab79df9d9b2efe0957cc5f9a71b9c0cec5e9a92c9107e414326e470ec68a213aaecc0'
7
- data.tar.gz: 6f9732bfb46252e50318d2fccf409aaabb07e110c2b6aaed150cabff4475bdb0cb9d4e1b2a887b9e87b65c948515667f6990f9d7460d2d66f5bb353355d6f85a
6
+ metadata.gz: '02690154f0a711b3cdeafe89b38d318d01b974e0ac78e5648d26ae8c76e44486b00973100076e17df7bbae1a9e1d01b4190c4242b479f538159a1eb5fd4d6236'
7
+ data.tar.gz: a65f3ebcdb0804789e0546db6ca5370056e93d4713bf0576133af58cc2e3dc6eb4005750d3677618121ef8f7ecb44e96a46f2b797a6cdbd23e4675eb89872e45
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- authentication-zero (2.15.1)
4
+ authentication-zero (2.15.4)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -1,3 +1,3 @@
1
1
  module AuthenticationZero
2
- VERSION = "2.15.1"
2
+ VERSION = "2.15.4"
3
3
  end
@@ -6,7 +6,7 @@ class Identity::EmailsController < ApplicationController
6
6
 
7
7
  def update
8
8
  if @user.update(user_params)
9
- render json: @user
9
+ render_show
10
10
  else
11
11
  render json: @user.errors, status: :unprocessable_entity
12
12
  end
@@ -20,4 +20,16 @@ class Identity::EmailsController < ApplicationController
20
20
  def user_params
21
21
  params.permit(:email)
22
22
  end
23
+
24
+ def render_show
25
+ if @user.email_previously_changed?
26
+ resend_email_verification; render(json: @user)
27
+ else
28
+ render json: @user
29
+ end
30
+ end
31
+
32
+ def resend_email_verification
33
+ UserMailer.with(user: @user).email_verification.deliver_later
34
+ end
23
35
  end
@@ -5,6 +5,7 @@ class RegistrationsController < ApplicationController
5
5
  @user = User.new(user_params)
6
6
 
7
7
  if @user.save
8
+ send_email_verification
8
9
  render json: @user, status: :created
9
10
  else
10
11
  render json: @user.errors, status: :unprocessable_entity
@@ -15,4 +16,8 @@ class RegistrationsController < ApplicationController
15
16
  def user_params
16
17
  params.permit(:email, :password, :password_confirmation)
17
18
  end
19
+
20
+ def send_email_verification
21
+ UserMailer.with(user: @user).email_verification.deliver_later
22
+ end
18
23
  end
@@ -9,7 +9,7 @@ class Identity::EmailsController < ApplicationController
9
9
 
10
10
  def update
11
11
  if @user.update(user_params)
12
- redirect_to root_path, notice: "Your email has been changed"
12
+ redirect_to_root
13
13
  else
14
14
  render :edit, status: :unprocessable_entity
15
15
  end
@@ -23,4 +23,17 @@ class Identity::EmailsController < ApplicationController
23
23
  def user_params
24
24
  params.permit(:email)
25
25
  end
26
+
27
+ def redirect_to_root
28
+ if @user.email_previously_changed?
29
+ resend_email_verification
30
+ redirect_to root_path, notice: "Your email has been changed"
31
+ else
32
+ redirect_to root_path
33
+ end
34
+ end
35
+
36
+ def resend_email_verification
37
+ UserMailer.with(user: @user).email_verification.deliver_later
38
+ end
26
39
  end
@@ -12,6 +12,7 @@ class RegistrationsController < ApplicationController
12
12
  session = @user.sessions.create!
13
13
  cookies.signed.permanent[:session_token] = { value: session.id, httponly: true }
14
14
 
15
+ send_email_verification
15
16
  redirect_to root_path, notice: "Welcome! You have signed up successfully"
16
17
  else
17
18
  render :new, status: :unprocessable_entity
@@ -22,4 +23,8 @@ class RegistrationsController < ApplicationController
22
23
  def user_params
23
24
  params.permit(:email, :password, :password_confirmation)
24
25
  end
26
+
27
+ def send_email_verification
28
+ UserMailer.with(user: @user).email_verification.deliver_later
29
+ end
25
30
  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 :email_verification_tokens do |t|
4
- t.references :user, null: false, foreign_key: true
4
+ t.references :user, null: false, foreign_key: false
5
5
  end
6
6
  end
7
7
  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 :password_reset_tokens do |t|
4
- t.references :user, null: false, foreign_key: true
4
+ t.references :user, null: false, foreign_key: false
5
5
  end
6
6
  end
7
7
  end
@@ -1,8 +1,8 @@
1
1
  class User < ApplicationRecord
2
2
  has_secure_password
3
3
 
4
- has_one :email_verification_token, dependent: :destroy
5
- has_one :password_reset_token, dependent: :destroy
4
+ has_one :email_verification_token
5
+ has_one :password_reset_token
6
6
 
7
7
  has_many :sessions, dependent: :destroy
8
8
  <%- if options.trackable? -%>
@@ -30,11 +30,8 @@ class User < ApplicationRecord
30
30
  sessions.where.not(id: Current.session).destroy_all
31
31
  end
32
32
 
33
- after_save_commit if: :email_previously_changed? do
34
- UserMailer.with(user: self).email_verification.deliver_later
35
- end
36
33
  <%- if options.trackable? %>
37
- after_save_commit if: :email_previously_changed? do
34
+ after_update if: :email_previously_changed? do
38
35
  events.create! action: "email_verification_requested"
39
36
  end
40
37
 
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.15.1
4
+ version: 2.15.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nixon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-06-01 00:00:00.000000000 Z
11
+ date: 2022-08-11 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: