rails_jwt_auth 1.7.0 → 1.7.1

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: bc1754797f099cba50a36044a69225fbeffee8e01120b9aa394209761d30eaf4
4
- data.tar.gz: da443b714e8d7af7fb687a66e46fc6f3a46feb8837239debd1d16c76c34a49dc
3
+ metadata.gz: b624ce7e99bced2abcbe29c05955af2fa4ccf7b6d9badc74e5effdd2b98ac4e9
4
+ data.tar.gz: 427995dd79006f041e27de387ce9affa2294d2eedcefcf02eaf502c3f9d60630
5
5
  SHA512:
6
- metadata.gz: f72dd3b12df746bd2d95291090b5e5f4dce0c0cdcba429b4de5ac2290c811e55637790cbbbb93209bf8184ae9a827986b1000b3d8c9fb834f2151e9b610ba993
7
- data.tar.gz: 68a3963c17ef09d9225550a79f3989572e5edb8b4c7023d40fca80b647c06c1cdd2848a0bbe76d0d11a339ffc88801d80f7f131ab829ddbb3ef60dabf6a2168a
6
+ metadata.gz: ffda5aa2b329f926133837ba6fa254643c0637eaef292b3f63ec4305dedd34f3e1d238fa52033bfbbe4e9407d916af6ff4fefcee2f58923d08a1e906b7991be9
7
+ data.tar.gz: d0a639b9e6345feaaa3d28095cbed507e549fa8a1d61c4f125cb79a7ee895ba937c1bdd13324d4742e5f6b7594bd6d4dee146b314301bc4b026b721b0bd6ad07
@@ -33,14 +33,14 @@ module RailsJwtAuth
33
33
 
34
34
  self.confirmation_token = SecureRandom.base58(24)
35
35
  self.confirmation_sent_at = Time.current
36
-
37
- RailsJwtAuth.send_email(:confirmation_instructions, self)
38
-
39
- if RailsJwtAuth.send_email_changed_notification
40
- RailsJwtAuth.send_email(:email_changed, self)
41
- end
42
36
  end
43
37
  end
38
+
39
+ if defined?(ActiveRecord) && ancestors.include?(ActiveRecord::Base)
40
+ after_commit :deliver_email_changed_emails, if: :saved_change_to_unconfirmed_email?
41
+ elsif defined?(Mongoid) && ancestors.include?(Mongoid::Document)
42
+ after_update :deliver_email_changed_emails, if: :unconfirmed_email_changed?
43
+ end
44
44
  end
45
45
  end
46
46
 
@@ -76,7 +76,7 @@ module RailsJwtAuth
76
76
 
77
77
  # supports email confirmation attr_accessor validation
78
78
  if respond_to?("#{email_field}_confirmation")
79
- self.instance_variable_set("@#{email_field}_confirmation", self[email_field])
79
+ instance_variable_set("@#{email_field}_confirmation", self[email_field])
80
80
  end
81
81
  end
82
82
 
@@ -92,6 +92,7 @@ module RailsJwtAuth
92
92
 
93
93
  def validate_confirmation
94
94
  return true unless confirmed_at
95
+
95
96
  email_field = RailsJwtAuth.email_field_name!
96
97
 
97
98
  if confirmed_at_was && !public_send("#{email_field}_changed?")
@@ -101,5 +102,15 @@ module RailsJwtAuth
101
102
  errors.add(:confirmation_token, :expired)
102
103
  end
103
104
  end
105
+
106
+ def deliver_email_changed_emails
107
+ # send confirmation to new email
108
+ RailsJwtAuth.send_email(:confirmation_instructions, self)
109
+
110
+ # send notify to old email
111
+ if RailsJwtAuth.send_email_changed_notification
112
+ RailsJwtAuth.send_email(:email_changed, self)
113
+ end
114
+ end
104
115
  end
105
116
  end
@@ -1,3 +1,3 @@
1
1
  module RailsJwtAuth
2
- VERSION = '1.7.0'
2
+ VERSION = '1.7.1'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_jwt_auth
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.0
4
+ version: 1.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - rjurado
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-15 00:00:00.000000000 Z
11
+ date: 2020-06-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bcrypt