rails_jwt_auth 1.6.1 → 1.7.0
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 +4 -4
- data/app/mailers/rails_jwt_auth/mailer.rb +17 -25
- data/app/models/concerns/rails_jwt_auth/confirmable.rb +3 -6
- data/app/models/concerns/rails_jwt_auth/invitable.rb +2 -3
- data/app/models/concerns/rails_jwt_auth/lockable.rb +1 -2
- data/app/models/concerns/rails_jwt_auth/recoverable.rb +2 -4
- data/lib/rails_jwt_auth.rb +5 -0
- data/lib/rails_jwt_auth/version.rb +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: bc1754797f099cba50a36044a69225fbeffee8e01120b9aa394209761d30eaf4
|
4
|
+
data.tar.gz: da443b714e8d7af7fb687a66e46fc6f3a46feb8837239debd1d16c76c34a49dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f72dd3b12df746bd2d95291090b5e5f4dce0c0cdcba429b4de5ac2290c811e55637790cbbbb93209bf8184ae9a827986b1000b3d8c9fb834f2151e9b610ba993
|
7
|
+
data.tar.gz: 68a3963c17ef09d9225550a79f3989572e5edb8b4c7023d40fca80b647c06c1cdd2848a0bbe76d0d11a339ffc88801d80f7f131ab829ddbb3ef60dabf6a2168a
|
@@ -2,9 +2,13 @@ if defined?(ActionMailer)
|
|
2
2
|
class RailsJwtAuth::Mailer < ApplicationMailer
|
3
3
|
default from: RailsJwtAuth.mailer_sender
|
4
4
|
|
5
|
-
|
5
|
+
before_action do
|
6
|
+
@user = RailsJwtAuth.model.find(params[:user_id])
|
7
|
+
@subject = I18n.t("rails_jwt_auth.mailer.#{action_name}.subject")
|
8
|
+
end
|
9
|
+
|
10
|
+
def confirmation_instructions
|
6
11
|
raise RailsJwtAuth::NotConfirmationsUrl unless RailsJwtAuth.confirmations_url.present?
|
7
|
-
@user = user
|
8
12
|
|
9
13
|
@confirmations_url = add_param_to_url(
|
10
14
|
RailsJwtAuth.confirmations_url,
|
@@ -12,19 +16,15 @@ if defined?(ActionMailer)
|
|
12
16
|
@user.confirmation_token
|
13
17
|
)
|
14
18
|
|
15
|
-
|
16
|
-
mail(to: @user.unconfirmed_email || @user[RailsJwtAuth.email_field_name], subject: subject)
|
19
|
+
mail(to: @user.unconfirmed_email || @user[RailsJwtAuth.email_field_name], subject: @subject)
|
17
20
|
end
|
18
21
|
|
19
|
-
def email_changed
|
20
|
-
@user
|
21
|
-
subject = I18n.t('rails_jwt_auth.mailer.email_changed.subject')
|
22
|
-
mail(to: @user[RailsJwtAuth.email_field_name!], subject: subject)
|
22
|
+
def email_changed
|
23
|
+
mail(to: @user[RailsJwtAuth.email_field_name!], subject: @subject)
|
23
24
|
end
|
24
25
|
|
25
|
-
def reset_password_instructions
|
26
|
+
def reset_password_instructions
|
26
27
|
raise RailsJwtAuth::NotResetPasswordsUrl unless RailsJwtAuth.reset_passwords_url.present?
|
27
|
-
@user = user
|
28
28
|
|
29
29
|
@reset_passwords_url = add_param_to_url(
|
30
30
|
RailsJwtAuth.reset_passwords_url,
|
@@ -32,13 +32,11 @@ if defined?(ActionMailer)
|
|
32
32
|
@user.reset_password_token
|
33
33
|
)
|
34
34
|
|
35
|
-
|
36
|
-
mail(to: @user[RailsJwtAuth.email_field_name], subject: subject)
|
35
|
+
mail(to: @user[RailsJwtAuth.email_field_name], subject: @subject)
|
37
36
|
end
|
38
37
|
|
39
|
-
def set_password_instructions
|
38
|
+
def set_password_instructions
|
40
39
|
raise RailsJwtAuth::NotSetPasswordsUrl unless RailsJwtAuth.set_passwords_url.present?
|
41
|
-
@user = user
|
42
40
|
|
43
41
|
@reset_passwords_url = add_param_to_url(
|
44
42
|
RailsJwtAuth.set_passwords_url,
|
@@ -46,13 +44,11 @@ if defined?(ActionMailer)
|
|
46
44
|
@user.reset_password_token
|
47
45
|
)
|
48
46
|
|
49
|
-
|
50
|
-
mail(to: @user[RailsJwtAuth.email_field_name], subject: subject)
|
47
|
+
mail(to: @user[RailsJwtAuth.email_field_name], subject: @subject)
|
51
48
|
end
|
52
49
|
|
53
|
-
def send_invitation
|
50
|
+
def send_invitation
|
54
51
|
raise RailsJwtAuth::NotInvitationsUrl unless RailsJwtAuth.invitations_url.present?
|
55
|
-
@user = user
|
56
52
|
|
57
53
|
@invitations_url = add_param_to_url(
|
58
54
|
RailsJwtAuth.invitations_url,
|
@@ -60,17 +56,13 @@ if defined?(ActionMailer)
|
|
60
56
|
@user.invitation_token
|
61
57
|
)
|
62
58
|
|
63
|
-
|
64
|
-
mail(to: @user[RailsJwtAuth.email_field_name], subject: subject)
|
59
|
+
mail(to: @user[RailsJwtAuth.email_field_name], subject: @subject)
|
65
60
|
end
|
66
61
|
|
67
|
-
def send_unlock_instructions
|
68
|
-
@user = user
|
69
|
-
subject = I18n.t('rails_jwt_auth.mailer.send_unlock_instructions.subject')
|
70
|
-
|
62
|
+
def send_unlock_instructions
|
71
63
|
@unlock_url = add_param_to_url(RailsJwtAuth.unlock_url, 'unlock_token', @user.unlock_token)
|
72
64
|
|
73
|
-
mail(to: @user[RailsJwtAuth.email_field_name], subject: subject)
|
65
|
+
mail(to: @user[RailsJwtAuth.email_field_name], subject: @subject)
|
74
66
|
end
|
75
67
|
|
76
68
|
protected
|
@@ -34,12 +34,10 @@ module RailsJwtAuth
|
|
34
34
|
self.confirmation_token = SecureRandom.base58(24)
|
35
35
|
self.confirmation_sent_at = Time.current
|
36
36
|
|
37
|
-
|
38
|
-
RailsJwtAuth.deliver_later ? mailer.deliver_later : mailer.deliver
|
37
|
+
RailsJwtAuth.send_email(:confirmation_instructions, self)
|
39
38
|
|
40
39
|
if RailsJwtAuth.send_email_changed_notification
|
41
|
-
|
42
|
-
RailsJwtAuth.deliver_later ? mailer.deliver_later : mailer.deliver
|
40
|
+
RailsJwtAuth.send_email(:email_changed, self)
|
43
41
|
end
|
44
42
|
end
|
45
43
|
end
|
@@ -58,8 +56,7 @@ module RailsJwtAuth
|
|
58
56
|
self.confirmation_sent_at = Time.current
|
59
57
|
return false unless save
|
60
58
|
|
61
|
-
|
62
|
-
RailsJwtAuth.deliver_later ? mailer.deliver_later : mailer.deliver
|
59
|
+
RailsJwtAuth.send_email(:confirmation_instructions, self)
|
63
60
|
true
|
64
61
|
end
|
65
62
|
|
@@ -112,9 +112,8 @@ module RailsJwtAuth
|
|
112
112
|
end
|
113
113
|
|
114
114
|
def send_invitation_mail
|
115
|
-
RailsJwtAuth.email_field_name! # ensure email field
|
116
|
-
|
117
|
-
RailsJwtAuth.deliver_later ? mailer.deliver_later : mailer.deliver
|
115
|
+
RailsJwtAuth.email_field_name! # ensure email field is valid
|
116
|
+
RailsJwtAuth.send_email(:send_invitation, self)
|
118
117
|
end
|
119
118
|
|
120
119
|
def invitation_period_valid?
|
@@ -68,8 +68,7 @@ module RailsJwtAuth
|
|
68
68
|
self.unlock_token = SecureRandom.base58(24)
|
69
69
|
save(validate: false)
|
70
70
|
|
71
|
-
|
72
|
-
RailsJwtAuth.deliver_later ? mailer.deliver_later : mailer.deliver
|
71
|
+
RailsJwtAuth.send_email(:send_unlock_instructions, self)
|
73
72
|
end
|
74
73
|
|
75
74
|
def access_locked?
|
@@ -40,8 +40,7 @@ module RailsJwtAuth
|
|
40
40
|
self.reset_password_sent_at = Time.current
|
41
41
|
return false unless save
|
42
42
|
|
43
|
-
|
44
|
-
RailsJwtAuth.deliver_later ? mailer.deliver_later : mailer.deliver
|
43
|
+
RailsJwtAuth.send_email(:reset_password_instructions, self)
|
45
44
|
end
|
46
45
|
|
47
46
|
def set_and_send_password_instructions
|
@@ -56,8 +55,7 @@ module RailsJwtAuth
|
|
56
55
|
self.reset_password_sent_at = Time.current
|
57
56
|
return false unless save
|
58
57
|
|
59
|
-
|
60
|
-
RailsJwtAuth.deliver_later ? mailer.deliver_later : mailer.deliver
|
58
|
+
RailsJwtAuth.send_email(:set_password_instructions, self)
|
61
59
|
true
|
62
60
|
end
|
63
61
|
|
data/lib/rails_jwt_auth.rb
CHANGED
@@ -114,4 +114,9 @@ module RailsJwtAuth
|
|
114
114
|
|
115
115
|
field_name
|
116
116
|
end
|
117
|
+
|
118
|
+
def self.send_email(method, user)
|
119
|
+
mailer = RailsJwtAuth::Mailer.with(user_id: user.id.to_s).public_send(method)
|
120
|
+
RailsJwtAuth.deliver_later ? mailer.deliver_later : mailer.deliver
|
121
|
+
end
|
117
122
|
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.
|
4
|
+
version: 1.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- rjurado
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-06-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bcrypt
|