quo_vadis 2.2.6 → 2.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 793c8183dd6e61c69255ca9e13a9726949591cbc4e3dda9890fb213848819dea
4
- data.tar.gz: a01e34b058359d91dac594c617a2c55550f16f2e607a9b254f2087eab9eadc10
3
+ metadata.gz: 99defadc14bc4d695dccfad2f131ea6817ae931b1af1a65cc2418a5c3dbe1444
4
+ data.tar.gz: 2585f246fe58c479cee88852a155aa66d1ae4ff3f18f9c353216529a096a1f75
5
5
  SHA512:
6
- metadata.gz: b5c29de9d14f2d2d14e4fcefa04379b0135c5720b27df6d3762c30503e121cb811f1e0248a76d589580931f953367c04f810d286df15204abe2c52b2df1c82cb
7
- data.tar.gz: 9afd5eb09d2b91db1a5c3023e2c2b4fccd545231b39188fa95acebab677549dc642a657797b8c2e59b83b00595ce21083ffeadf0be2f4c17aa09e64496a9a672
6
+ metadata.gz: 04a76b0961a32febb4860656ba4a45faaeec652c3174450393583c3667af51950b55f8c9995b123ee135396c442da607512541d8dd01c6cedbfb279f736085aa
7
+ data.tar.gz: e38c400e9a0151691616e522218954d76347fec42cfa479d240166d8bdae95c75cd00d7e56cb4a92c8ec7da7a53b45b6847b1b942df3043f7ddc49bed1ecef56
data/CHANGELOG.md CHANGED
@@ -4,6 +4,13 @@
4
4
  ## HEAD
5
5
 
6
6
 
7
+ ## 2.3.0 (18 November 2025)
8
+
9
+ * Upon confirmation redirect to original path.
10
+ * Remove concept of after_signup route.
11
+ * Enable OTP to be given in i18n mailer subject.
12
+
13
+
7
14
  ## 2.2.6 (17 November 2025)
8
15
 
9
16
  * Make permitting of password updates explicit.
data/README.md CHANGED
@@ -197,15 +197,15 @@ Your new user sign-up form ([example](https://github.com/airblade/quo_vadis/blob
197
197
 
198
198
  In your controller, use the [`#login`](#loginmodel-browser_session--true-metadata-) method to log in your new user. The optional second argument specifies for how long the user should be logged in, and any metadata you supply is logged in the audit log.
199
199
 
200
- After logging in the user, redirect them wherever you like. You can use `qv.path_after_signup` which resolves to the first of these routes that exists: `:after_signup`, `:after_login`, the root route.
200
+ After logging in the user, redirect them wherever you like as normal.
201
201
 
202
202
  ```ruby
203
203
  class UsersController < ApplicationController
204
204
  def create
205
205
  @user = User.new user_params
206
206
  if @user.save
207
- login @user
208
- redirect_to qv.path_after_signup
207
+ login @user # <-- add this
208
+ redirect_to dashboard_path
209
209
  else
210
210
  # ...
211
211
  end
@@ -219,21 +219,15 @@ class UsersController < ApplicationController
219
219
  end
220
220
  ```
221
221
 
222
- ```ruby
223
- # config/routes.rb
224
- get '/dashboard', as: 'after_login'
225
- ```
226
-
227
-
228
222
  ### Sign up with account confirmation
229
223
 
230
224
  Follow the steps above for sign-up.
231
225
 
232
- After you have logged in the user and redirected them (to any page which requires being logged in), QuoVadis detects that they need to confirm their account. QuoVadis emails them a 6-digit confirmation code and redirects them to the confirmation page where they can enter that code.
226
+ After you have logged in the user and redirected them, QuoVadis detects that they need to confirm their account. QuoVadis emails them a 6-digit confirmation code and redirects them to the confirmation page where they can enter that code.
233
227
 
234
228
  The confirmation code is valid for `QuoVadis.account_confirmation_otp_lifetime`.
235
229
 
236
- Once the user has confirmed their account, they will be redirected to `qv.path_after_signup` which resolves to the first of these routes that exists: `:after_signup`, `:after_login`, the root route. Add whichever works best for you.
230
+ Once the user has confirmed their account, they will be redirected to the page they requested before they were redirected to the confirmation page.
237
231
 
238
232
  You need to write the email view ([example](https://github.com/airblade/quo_vadis/blob/master/app/views/quo_vadis/mailer/account_confirmation.text.erb)). It must be in `app/views/quo_vadis/mailer/account_confirmation.{text,html}.erb` and output the `@otp` variable. See the [Configuration](#configuration) section for how to set QuoVadis's emails' from addresses, headers, etc.
239
233
 
@@ -555,7 +549,7 @@ get '/profile', to: 'profiles#show', as: 'after_password_change'
555
549
 
556
550
  ### I18n
557
551
 
558
- All QuoVadis' flash messages are set via [i18n](https://github.com/airblade/quo_vadis/blob/master/config/locales/quo_vadis.en.yml).
552
+ All QuoVadis' text (flash messages, mail subjects, and log messages) is set via [i18n](https://github.com/airblade/quo_vadis/blob/master/config/locales/quo_vadis.en.yml).
559
553
 
560
554
  You can override any of the messages with your own locale file at `config/locales/quo_vadis.en.yml`.
561
555
 
@@ -7,7 +7,7 @@ module QuoVadis
7
7
  @account = find_pending_account_from_session
8
8
 
9
9
  unless @account
10
- redirect_to qv.path_after_signup, alert: QuoVadis.translate('flash.confirmation.unknown')
10
+ redirect_to qv.path_after_authentication, alert: QuoVadis.translate('flash.confirmation.unknown')
11
11
  end
12
12
  end
13
13
 
@@ -16,7 +16,7 @@ module QuoVadis
16
16
  @account = find_pending_account_from_session
17
17
 
18
18
  unless @account
19
- redirect_to qv.path_after_signup, alert: QuoVadis.translate('flash.confirmation.unknown')
19
+ redirect_to qv.path_after_authentication, alert: QuoVadis.translate('flash.confirmation.unknown')
20
20
  return
21
21
  end
22
22
 
@@ -39,7 +39,7 @@ module QuoVadis
39
39
  session.delete :account_pending_confirmation
40
40
  session.delete :account_confirmation_expires_at
41
41
 
42
- redirect_to qv.path_after_signup, notice: QuoVadis.translate('flash.confirmation.confirmed')
42
+ redirect_to qv.path_after_authentication, notice: QuoVadis.translate('flash.confirmation.confirmed')
43
43
  end
44
44
 
45
45
 
@@ -47,7 +47,7 @@ module QuoVadis
47
47
  @account = find_pending_account_from_session
48
48
 
49
49
  unless @account
50
- redirect_to qv.path_after_signup, alert: QuoVadis.translate('flash.confirmation.unknown')
50
+ redirect_to qv.path_after_authentication, alert: QuoVadis.translate('flash.confirmation.unknown')
51
51
  end
52
52
 
53
53
  qv.request_confirmation @account.model
@@ -5,12 +5,12 @@ module QuoVadis
5
5
 
6
6
  def reset_password
7
7
  @otp = params[:otp]
8
- _mail params[:email], QuoVadis.translate('mailer.password_reset.subject')
8
+ _mail params[:email], QuoVadis.translate('mailer.password_reset.subject', otp: params[:otp])
9
9
  end
10
10
 
11
11
  def account_confirmation
12
12
  @otp = params[:otp]
13
- _mail params[:email], QuoVadis.translate('mailer.confirmation.subject')
13
+ _mail params[:email], QuoVadis.translate('mailer.confirmation.subject', otp: params[:otp])
14
14
  end
15
15
 
16
16
  def email_change_notification
@@ -35,9 +35,9 @@ en:
35
35
  invalidated: You have invalidated your 2FA credentials and recovery codes.
36
36
  mailer:
37
37
  password_reset:
38
- subject: Change your password
38
+ subject: Your password reset code is %{otp}
39
39
  confirmation:
40
- subject: Please confirm your account
40
+ subject: Your account confirmation code is %{otp}
41
41
  notification:
42
42
  email_change: Your email address has been changed
43
43
  identifier_change: Your %{identifier} has been changed
@@ -34,6 +34,7 @@ module QuoVadis
34
34
  if logged_in?
35
35
  if QuoVadis.accounts_require_confirmation && !authenticated_model.qv_account.confirmed?
36
36
  qv.request_confirmation authenticated_model
37
+ session[:qv_bookmark] = request.original_fullpath
37
38
  redirect_to quo_vadis.confirm_path
38
39
  end
39
40
  return
@@ -217,13 +218,6 @@ module QuoVadis
217
218
  Log.create account: account, action: action, ip: request.remote_ip, metadata: metadata
218
219
  end
219
220
 
220
- def path_after_signup
221
- return main_app.after_signup_path if main_app.respond_to?(:after_signup_path)
222
- return main_app.after_login_path if main_app.respond_to?(:after_login_path)
223
- return main_app.root_path if main_app.respond_to?(:root_path)
224
- raise RuntimeError, 'Missing routes: after_signup_path, after_login_path, root_path; define at least one of them.'
225
- end
226
-
227
221
  def path_after_authentication
228
222
  if (bookmark = rails_session[:qv_bookmark])
229
223
  rails_session.delete :qv_bookmark
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module QuoVadis
4
- VERSION = '2.2.6'
4
+ VERSION = '2.3.0'
5
5
  end
@@ -24,11 +24,6 @@ class SignUpsController < ApplicationController
24
24
  @user = User.find params[:id]
25
25
  end
26
26
 
27
- def confirmed
28
- # Here we could send an email.
29
- redirect_to after_login_path
30
- end
31
-
32
27
  private
33
28
 
34
29
  def user_params
@@ -1,6 +1,5 @@
1
1
  Rails.application.routes.draw do
2
2
  resources :users
3
- get '/sign_ups/confirmed', to: 'sign_ups#confirmed', as: 'after_signup'
4
3
  resources :sign_ups
5
4
  resources :articles do
6
5
  collection do
@@ -30,8 +30,6 @@ class AccountConfirmationTest < IntegrationTest
30
30
  post quo_vadis.confirm_path(otp: code)
31
31
 
32
32
  # verify logged in
33
- assert_redirected_to '/sign_ups/confirmed'
34
- follow_redirect!
35
33
  assert_redirected_to '/articles/secret'
36
34
  assert_equal 'Thanks for confirming your account.', flash[:notice]
37
35
  assert QuoVadis::Account.last.confirmed?
@@ -64,7 +62,7 @@ class AccountConfirmationTest < IntegrationTest
64
62
 
65
63
  post quo_vadis.confirm_path(otp: code)
66
64
  assert_equal 'You have already confirmed your account.', flash[:alert]
67
- assert_redirected_to '/sign_ups/confirmed'
65
+ assert_redirected_to '/articles/secret'
68
66
  end
69
67
 
70
68
 
@@ -21,7 +21,7 @@ class MailerTest < ActionMailer::TestCase
21
21
 
22
22
  assert_equal ['foo@example.com'], email.to
23
23
  assert_equal ['bar@example.com'], email.from
24
- assert_equal 'Change your password', email.subject
24
+ assert_equal 'Your password reset code is 314159', email.subject
25
25
  assert_equal read_fixture('reset_password.text').join, email.body.to_s
26
26
  end
27
27
 
@@ -38,7 +38,7 @@ class MailerTest < ActionMailer::TestCase
38
38
 
39
39
  assert_equal ['foo@example.com'], email.to
40
40
  assert_equal ['bar@example.com'], email.from
41
- assert_equal 'Please confirm your account', email.subject
41
+ assert_equal 'Your account confirmation code is 271828', email.subject
42
42
  assert_equal read_fixture('account_confirmation.text').join, email.body.to_s
43
43
  end
44
44
 
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.2.6
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Stewart