authentication-zero 2.15.2 → 2.15.5

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: 57381cfe8cb5f43de1b8d8946ef872528166b9d5919d3fa612d811aded172697
4
- data.tar.gz: 98b95b24b18b7f5f8113194712261ac840405fd5df47ffd1a51e7df45e9242b8
3
+ metadata.gz: d543ebd70ad0bc5b3d734d96c106cabef8b8219ad44fce3a75ce90d7670d9084
4
+ data.tar.gz: a4c506a4746e6c8aba5b09dbb26d7f93d9fde4c52dc5fb7690c1e6e41f0cf988
5
5
  SHA512:
6
- metadata.gz: a9537217a53d7700bdb232779bb4d1c7706d045646648ec6788b9cb11e32da79b18f127d9d9f998239b7fcc74aa9c76e321d564e443b7a772c7c4cde4e30dfc3
7
- data.tar.gz: 759a0cbab559acb22c223c990a0d169420c1f0b7f1c75606737ef6703fcf4008221073f5817fdf215b1c139522e45f4bf9381fa84a5b3fbff23ff3209e3c75b9
6
+ metadata.gz: b474eaf63504fb13acb7c6444757070faf3375059aea062026c3329bf5f2e270a52f08a7cdead777ce12d639ae558e6ecac6a9e6dc83bd576f75e7f109f22aa7
7
+ data.tar.gz: 50af59feb9c1effb0e3b0260bf2f6420af9bae84ae7cbeab13fe2b0de508c23a58e52f4db7c5d6a8cac38d937d4e5d0f4c0e498af16a26657d5461c2d1b788ab
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- authentication-zero (2.15.2)
4
+ authentication-zero (2.15.5)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -1,3 +1,3 @@
1
1
  module AuthenticationZero
2
- VERSION = "2.15.2"
2
+ VERSION = "2.15.5"
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
@@ -26,17 +26,10 @@ class User < ApplicationRecord
26
26
  self.verified = false
27
27
  end
28
28
 
29
- after_create_commit do
30
- UserMailer.with(user: self).email_verification.deliver_later
31
- end
32
-
33
29
  after_update if: :password_digest_previously_changed? do
34
30
  sessions.where.not(id: Current.session).destroy_all
35
31
  end
36
32
 
37
- after_update if: :email_previously_changed? do
38
- UserMailer.with(user: self).email_verification.deliver_later
39
- end
40
33
  <%- if options.trackable? %>
41
34
  after_update if: :email_previously_changed? do
42
35
  events.create! action: "email_verification_requested"
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.2
4
+ version: 2.15.5
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-03 00:00:00.000000000 Z
11
+ date: 2022-08-19 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: