quo_vadis 2.1.2 → 2.1.3

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: 5b81cb83f9cd0b6bb6e9af4015dba59b5cef0f5c3fccd5a82ee6d7e1bbc5768a
4
- data.tar.gz: 8a9f5f0c013ec89de6849e9ddb3393fee46b84a2d08b20e606126cf97bba8032
3
+ metadata.gz: 707a011642d93c975b94f1c99c157decdec10c8138edf4e3b4dcf884438abac8
4
+ data.tar.gz: 8b5e4a2396909660b86ff6de1cee25dd574fe6ca1d10ccf1831c51381e61a2e4
5
5
  SHA512:
6
- metadata.gz: a7b5e766f22e55e5bc269d00e6fb9132cc54ba2523a72996d0d7da478dbf0662764d29265c591f5847d5f2cfaeaca1e78fb4d48fb8fecb24af0bee9e9c2047e2
7
- data.tar.gz: 47bf8bba82c90f3b7527be6a316ec8f9a4b229077a6846454abecebd6d2ae29910f7e416635d9cc1d54e3b99fe87d4c7d0ca871741907f1987d1ee42bf79994b
6
+ metadata.gz: c1aa7cb7ee6c63886f3a8c322f98bb14ea54a4c997d74103e2f4db9f787c65fd3853eb8d771cc7b85c6ea99a1c1a92ee5a7c7db10b29f8d1d1d88f4682f3e8b7
7
+ data.tar.gz: 88f33eb05eafc2746bc8295f9606f441d99aa24edd422f9a800909008dca1eaded9800d86ec9dbe9b292449b7ec24b8458ec478257885d6f0ea0853ea6e2744c
data/CHANGELOG.md CHANGED
@@ -4,6 +4,16 @@
4
4
  ## HEAD
5
5
 
6
6
 
7
+ ## 2.1.3 (30 September 2021)
8
+
9
+ * Pass IP and timestamp as paramenters to mailer.
10
+
11
+
12
+ ## 2.1.2 (30 September 2021)
13
+
14
+ * Delete existing recovery codes when generating new ones.
15
+
16
+
7
17
  ## 2.1.1 (8 July 2021)
8
18
 
9
19
  * Remove unnecessary route names.
@@ -17,7 +17,7 @@ module QuoVadis
17
17
 
18
18
  if account
19
19
  token = QuoVadis::PasswordResetToken.generate account
20
- QuoVadis.deliver :reset_password, email: account.model.email, url: quo_vadis.password_reset_url(token)
20
+ QuoVadis.deliver :reset_password, {email: account.model.email, url: quo_vadis.password_reset_url(token)}
21
21
  end
22
22
 
23
23
  redirect_to password_resets_path, notice: QuoVadis.translate('flash.password_reset.create')
@@ -14,52 +14,52 @@ module QuoVadis
14
14
  end
15
15
 
16
16
  def email_change_notification
17
- @timestamp = Time.now
18
- @ip = QuoVadis::CurrentRequestDetails.ip
17
+ @timestamp = params[:timestamp]
18
+ @ip = params[:ip]
19
19
  _mail params[:email], QuoVadis.translate('mailer.notification.email_change')
20
20
  end
21
21
 
22
22
  def identifier_change_notification
23
- @timestamp = Time.now
23
+ @timestamp = params[:timestamp]
24
24
  @identifier = params[:identifier]
25
- @ip = QuoVadis::CurrentRequestDetails.ip
25
+ @ip = params[:ip]
26
26
  _mail params[:email], QuoVadis.translate('mailer.notification.identifier_change',
27
27
  identifier: params[:identifier])
28
28
  end
29
29
 
30
30
  def password_change_notification
31
- @timestamp = Time.now
32
- @ip = QuoVadis::CurrentRequestDetails.ip
31
+ @timestamp = params[:timestamp]
32
+ @ip = params[:ip]
33
33
  _mail params[:email], QuoVadis.translate('mailer.notification.password_change')
34
34
  end
35
35
 
36
36
  def password_reset_notification
37
- @timestamp = Time.now
38
- @ip = QuoVadis::CurrentRequestDetails.ip
37
+ @timestamp = params[:timestamp]
38
+ @ip = params[:ip]
39
39
  _mail params[:email], QuoVadis.translate('mailer.notification.password_reset')
40
40
  end
41
41
 
42
42
  def totp_setup_notification
43
- @timestamp = Time.now
44
- @ip = QuoVadis::CurrentRequestDetails.ip
43
+ @timestamp = params[:timestamp]
44
+ @ip = params[:ip]
45
45
  _mail params[:email], QuoVadis.translate('mailer.notification.totp_setup')
46
46
  end
47
47
 
48
48
  def totp_reuse_notification
49
- @timestamp = Time.now
50
- @ip = QuoVadis::CurrentRequestDetails.ip
49
+ @timestamp = params[:timestamp]
50
+ @ip = params[:ip]
51
51
  _mail params[:email], QuoVadis.translate('mailer.notification.totp_reuse')
52
52
  end
53
53
 
54
54
  def twofa_deactivated_notification
55
- @timestamp = Time.now
56
- @ip = QuoVadis::CurrentRequestDetails.ip
55
+ @timestamp = params[:timestamp]
56
+ @ip = params[:ip]
57
57
  _mail params[:email], QuoVadis.translate('mailer.notification.twofa_deactivated')
58
58
  end
59
59
 
60
60
  def recovery_codes_generation_notification
61
- @timestamp = Time.now
62
- @ip = QuoVadis::CurrentRequestDetails.ip
61
+ @timestamp = params[:timestamp]
62
+ @ip = params[:ip]
63
63
  _mail params[:email], QuoVadis.translate('mailer.notification.recovery_codes_generation')
64
64
  end
65
65
 
@@ -87,7 +87,7 @@ module QuoVadis
87
87
 
88
88
  def request_confirmation(model)
89
89
  token = QuoVadis::AccountConfirmationToken.generate model.qv_account
90
- QuoVadis.deliver :account_confirmation, email: model.email, url: quo_vadis.confirmation_url(token)
90
+ QuoVadis.deliver :account_confirmation, {email: model.email, url: quo_vadis.confirmation_url(token)}
91
91
  session[:account_pending_confirmation] = model.qv_account.id
92
92
 
93
93
  flash[:notice] = QuoVadis.translate 'flash.confirmation.create'
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module QuoVadis
4
- VERSION = '2.1.2'
4
+ VERSION = '2.1.3'
5
5
  end
data/lib/quo_vadis.rb CHANGED
@@ -73,12 +73,14 @@ module QuoVadis
73
73
  end
74
74
 
75
75
  def notify(action, params)
76
- QuoVadis::Mailer.with(params).send(action).deliver_later
76
+ deliver(action, params, later: true)
77
77
  end
78
78
 
79
- def deliver(action, params)
80
- mail = QuoVadis::Mailer.with(params).send(action)
81
- QuoVadis.enqueue_transactional_emails ?
79
+ def deliver(action, params, later: QuoVadis.enqueue_transactional_emails)
80
+ mail = QuoVadis::Mailer
81
+ .with(params.merge(ip: QuoVadis::CurrentRequestDetails.ip, timestamp: Time.now))
82
+ .send(action)
83
+ later ?
82
84
  mail.deliver_later :
83
85
  mail.deliver_now
84
86
  end
@@ -44,14 +44,16 @@ class MailerTest < ActionMailer::TestCase
44
44
 
45
45
 
46
46
  test 'email change notification' do
47
- email = QuoVadis::Mailer.with(email: 'Foo <foo@example.com>').email_change_notification
47
+ email = QuoVadis::Mailer.with(
48
+ email: 'Foo <foo@example.com>',
49
+ ip: '1.2.3.4',
50
+ timestamp: Time.now
51
+ ).email_change_notification
48
52
 
49
53
  # freeze_time
50
54
 
51
55
  assert_emails 1 do
52
- QuoVadis::CurrentRequestDetails.set(ip: '1.2.3.4') do
53
- email.deliver_now
54
- end
56
+ email.deliver_now
55
57
  end
56
58
 
57
59
  assert_equal ['foo@example.com'], email.to
@@ -62,14 +64,17 @@ class MailerTest < ActionMailer::TestCase
62
64
 
63
65
 
64
66
  test 'identifier change notification' do
65
- email = QuoVadis::Mailer.with(email: 'Foo <foo@example.com>', identifier: 'email').identifier_change_notification
67
+ email = QuoVadis::Mailer.with(
68
+ email: 'Foo <foo@example.com>',
69
+ identifier: 'email',
70
+ ip: '1.2.3.4',
71
+ timestamp: Time.now
72
+ ).identifier_change_notification
66
73
 
67
74
  # freeze_time
68
75
 
69
76
  assert_emails 1 do
70
- QuoVadis::CurrentRequestDetails.set(ip: '1.2.3.4') do
71
- email.deliver_now
72
- end
77
+ email.deliver_now
73
78
  end
74
79
 
75
80
  assert_equal ['foo@example.com'], email.to
@@ -80,14 +85,16 @@ class MailerTest < ActionMailer::TestCase
80
85
 
81
86
 
82
87
  test 'password change notification' do
83
- email = QuoVadis::Mailer.with(email: 'Foo <foo@example.com>').password_change_notification
88
+ email = QuoVadis::Mailer.with(
89
+ email: 'Foo <foo@example.com>',
90
+ ip: '1.2.3.4',
91
+ timestamp: Time.now
92
+ ).password_change_notification
84
93
 
85
94
  # freeze_time
86
95
 
87
96
  assert_emails 1 do
88
- QuoVadis::CurrentRequestDetails.set(ip: '1.2.3.4') do
89
- email.deliver_now
90
- end
97
+ email.deliver_now
91
98
  end
92
99
 
93
100
  assert_equal ['foo@example.com'], email.to
@@ -98,14 +105,16 @@ class MailerTest < ActionMailer::TestCase
98
105
 
99
106
 
100
107
  test 'password reset notification' do
101
- email = QuoVadis::Mailer.with(email: 'Foo <foo@example.com>').password_reset_notification
108
+ email = QuoVadis::Mailer.with(
109
+ email: 'Foo <foo@example.com>',
110
+ ip: '1.2.3.4',
111
+ timestamp: Time.now
112
+ ).password_reset_notification
102
113
 
103
114
  # freeze_time
104
115
 
105
116
  assert_emails 1 do
106
- QuoVadis::CurrentRequestDetails.set(ip: '1.2.3.4') do
107
- email.deliver_now
108
- end
117
+ email.deliver_now
109
118
  end
110
119
 
111
120
  assert_equal ['foo@example.com'], email.to
@@ -116,14 +125,16 @@ class MailerTest < ActionMailer::TestCase
116
125
 
117
126
 
118
127
  test 'totp setup notification' do
119
- email = QuoVadis::Mailer.with(email: 'Foo <foo@example.com>').totp_setup_notification
128
+ email = QuoVadis::Mailer.with(
129
+ email: 'Foo <foo@example.com>',
130
+ ip: '1.2.3.4',
131
+ timestamp: Time.now
132
+ ).totp_setup_notification
120
133
 
121
134
  # freeze_time
122
135
 
123
136
  assert_emails 1 do
124
- QuoVadis::CurrentRequestDetails.set(ip: '1.2.3.4') do
125
- email.deliver_now
126
- end
137
+ email.deliver_now
127
138
  end
128
139
 
129
140
  assert_equal ['foo@example.com'], email.to
@@ -134,14 +145,16 @@ class MailerTest < ActionMailer::TestCase
134
145
 
135
146
 
136
147
  test 'totp reuse notification' do
137
- email = QuoVadis::Mailer.with(email: 'Foo <foo@example.com>').totp_reuse_notification
148
+ email = QuoVadis::Mailer.with(
149
+ email: 'Foo <foo@example.com>',
150
+ ip: '1.2.3.4',
151
+ timestamp: Time.now
152
+ ).totp_reuse_notification
138
153
 
139
154
  # freeze_time
140
155
 
141
156
  assert_emails 1 do
142
- QuoVadis::CurrentRequestDetails.set(ip: '1.2.3.4') do
143
- email.deliver_now
144
- end
157
+ email.deliver_now
145
158
  end
146
159
 
147
160
  assert_equal ['foo@example.com'], email.to
@@ -152,14 +165,16 @@ class MailerTest < ActionMailer::TestCase
152
165
 
153
166
 
154
167
  test '2fa deactivated notification' do
155
- email = QuoVadis::Mailer.with(email: 'Foo <foo@example.com>').twofa_deactivated_notification
168
+ email = QuoVadis::Mailer.with(
169
+ email: 'Foo <foo@example.com>',
170
+ ip: '1.2.3.4',
171
+ timestamp: Time.now
172
+ ).twofa_deactivated_notification
156
173
 
157
174
  # freeze_time
158
175
 
159
176
  assert_emails 1 do
160
- QuoVadis::CurrentRequestDetails.set(ip: '1.2.3.4') do
161
- email.deliver_now
162
- end
177
+ email.deliver_now
163
178
  end
164
179
 
165
180
  assert_equal ['foo@example.com'], email.to
@@ -170,14 +185,16 @@ class MailerTest < ActionMailer::TestCase
170
185
 
171
186
 
172
187
  test 'recovery codes generation notification' do
173
- email = QuoVadis::Mailer.with(email: 'Foo <foo@example.com>').recovery_codes_generation_notification
188
+ email = QuoVadis::Mailer.with(
189
+ email: 'Foo <foo@example.com>',
190
+ ip: '1.2.3.4',
191
+ timestamp: Time.now
192
+ ).recovery_codes_generation_notification
174
193
 
175
194
  # freeze_time
176
195
 
177
196
  assert_emails 1 do
178
- QuoVadis::CurrentRequestDetails.set(ip: '1.2.3.4') do
179
- email.deliver_now
180
- end
197
+ email.deliver_now
181
198
  end
182
199
 
183
200
  assert_equal ['foo@example.com'], email.to
@@ -13,8 +13,11 @@ class AccountTest < ActiveSupport::TestCase
13
13
 
14
14
 
15
15
  test 'notifies on identifier change when notifier is not email' do
16
+ freeze_time
16
17
  p = Person.create! username: 'bob', email: 'bob@example.com', password: 'secretsecret'
17
- assert_enqueued_email_with QuoVadis::Mailer, :identifier_change_notification, args: {email: 'bob@example.com', identifier: 'username'} do
18
+ assert_enqueued_email_with QuoVadis::Mailer,
19
+ :identifier_change_notification,
20
+ args: {email: 'bob@example.com', identifier: 'username', ip: nil, timestamp: Time.now} do
18
21
  assert_enqueued_emails 1 do
19
22
  p.update username: 'robert@example.com'
20
23
  end
@@ -23,8 +26,11 @@ class AccountTest < ActiveSupport::TestCase
23
26
 
24
27
 
25
28
  test 'does not notify on identifier change when notifier is email' do
29
+ freeze_time
26
30
  u = User.create! name: 'bob', email: 'bob@example.com', password: '123456789abc'
27
- assert_enqueued_email_with QuoVadis::Mailer, :email_change_notification, args: {email: 'bob@example.com'} do
31
+ assert_enqueued_email_with QuoVadis::Mailer,
32
+ :email_change_notification,
33
+ args: {email: 'bob@example.com', ip: nil, timestamp: Time.now} do
28
34
  assert_enqueued_emails 1 do
29
35
  u.update email: 'robert@example.com'
30
36
  end
@@ -58,8 +58,11 @@ class ModelTest < ActiveSupport::TestCase
58
58
 
59
59
 
60
60
  test 'notifies on email change' do
61
+ freeze_time
61
62
  u = User.create! name: 'bob', email: 'bob@example.com', password: '123456789abc'
62
- assert_enqueued_email_with QuoVadis::Mailer, :email_change_notification, args: {email: 'bob@example.com'} do
63
+ assert_enqueued_email_with QuoVadis::Mailer,
64
+ :email_change_notification,
65
+ args: {email: 'bob@example.com', ip: nil, timestamp: Time.now} do
63
66
  u.update email: 'robert@example.com'
64
67
  end
65
68
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quo_vadis
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.2
4
+ version: 2.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Stewart
@@ -224,7 +224,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
224
224
  - !ruby/object:Gem::Version
225
225
  version: '0'
226
226
  requirements: []
227
- rubygems_version: 3.1.4
227
+ rubygems_version: 3.1.2
228
228
  signing_key:
229
229
  specification_version: 4
230
230
  summary: Multifactor authentication for Rails 6.