quo_vadis 2.1.8 → 2.1.10

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: d11498bfa66e0397304c2d9a0f8ac504037f97beac4fd039fe6c8d0299696531
4
- data.tar.gz: 2d1e267c7b55740c72087e297960ff6ececb1caee45a17eb588bf7e44ba64d31
3
+ metadata.gz: f75e1f5d40a86773e5cec5133d3822431d8ed76e581d7e712912481ae56ec29a
4
+ data.tar.gz: 3789a04b43d20d1c3b4e4aaf6e5c8b88f53c4bc97fce5ee4b546063e1bfa9801
5
5
  SHA512:
6
- metadata.gz: e4e7c7bb2996556b35b153c56916aef9834dcac2abea08ede8becc14e030d8f4ea1444f9286c1ca9b728c1a13c16d8d9b2e701255d57b769c7dc9abefa84a976
7
- data.tar.gz: f466404a5ba44bfd506cbcd2fdc7b2f2d142ecab419363e3c368bb5eca67cfc78829afa698b8b0dc1cc76210b531a32a44c3bfdcd1ae709cf9eafe740861f089
6
+ metadata.gz: ac21c181a2339c6d515ae2c7defe20ced03c103ac9e144ca4edcf3169d0ea4bafa18f4a2011912c611310e0adf5736285f7d8b2dff5b031468e735940bcbc3b0
7
+ data.tar.gz: 432bb81c9d8de26a659a718a533579bdd982c4565ae5df96511dc5ec60bf84c4d4665c694e1db9b0837434b6a9d5d43a9db7006b6e278a1b9d1c9d8cf2f54c2e
data/CHANGELOG.md CHANGED
@@ -4,6 +4,16 @@
4
4
  ## HEAD
5
5
 
6
6
 
7
+ ## 2.1.10 (14 September 2022)
8
+
9
+ * Enable configuration of mailer superclass.
10
+
11
+
12
+ ## 2.1.9 (13 September 2022)
13
+
14
+ * Enable code to be run after sign up.
15
+
16
+
7
17
  ## 2.1.8 (18 June 2022)
8
18
 
9
19
  * Extract convenience method for has authentication account.
@@ -35,7 +45,7 @@
35
45
 
36
46
  ## 2.1.3 (30 September 2021)
37
47
 
38
- * Pass IP and timestamp as paramenters to mailer.
48
+ * Pass IP and timestamp as parameters to mailer.
39
49
 
40
50
 
41
51
  ## 2.1.2 (30 September 2021)
data/README.md CHANGED
@@ -177,7 +177,7 @@ Your new user sign-up form ([example](https://github.com/airblade/quo_vadis/blob
177
177
 
178
178
  In your controller, use the `#login` method to log in your new user. The optional second argument sets the length of the session (defaults to the browser session) - see the description above in the Controllers section).
179
179
 
180
- After logging in the user, redirect them to `qv.path_after_authentication` which resolves to a route named `:after_login`, if you have one, or your root route.
180
+ 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.
181
181
 
182
182
  ```ruby
183
183
  class UsersController < ApplicationController
@@ -185,7 +185,7 @@ class UsersController < ApplicationController
185
185
  @user = User.new user_params
186
186
  if @user.save
187
187
  login @user
188
- redirect_to qv.path_after_authentication
188
+ redirect_to qv.path_after_signup
189
189
  else
190
190
  # ...
191
191
  end
@@ -258,10 +258,7 @@ Next, write the page where the user can amend their email address if they made a
258
258
 
259
259
  Finally, write the page where people can put in their identifier (not their email, unless the identifier is email) again to request another confirmation email ([example](https://github.com/airblade/quo_vadis/blob/master/app/views/quo_vadis/confirmations/new.html.erb)). It must be in `app/views/quo_vadis/confirmations/new.html.:format`.
260
260
 
261
- After the user has confirmed their account, they will be logged in and redirected to the first of these that exists:
262
-
263
- - a route named `:after_login`;
264
- - your root route.
261
+ After the user has confirmed their account, they will be logged in and redirected to `qv.path_after_signup` which resolves to the first of these routes that exists: `:after_signup`, `:after_login`, the root route.
265
262
 
266
263
  So add whichever works best for you.
267
264
 
@@ -469,6 +466,10 @@ __`account_confirmation_token_lifetime`__ (`ActiveSupport::Duration` | integer)
469
466
 
470
467
  The `Duration` or number of seconds for which an account-confirmation token is valid.
471
468
 
469
+ __`mailer_superclass`__ (string)
470
+
471
+ The class from which QuoVadis's mailer inherits.
472
+
472
473
  __`mail_headers`__ (hash)
473
474
 
474
475
  Mail headers which QuoVadis' emails should have.
@@ -518,12 +519,13 @@ end
518
519
 
519
520
  __Routes__
520
521
 
521
- You can set up your post-authentication and post-password-change routes. If you don't, you must have a root route. For example:
522
+ You can set up your post-signup, post-authentication, and post-password-change routes. If you don't, you must have a root route. For example:
522
523
 
523
524
  ```ruby
524
525
  # config/routes.rb
525
- get '/dashboard', to: 'dashboards#show', as: 'after_login'
526
- get '/profile', to: 'profiles#show', as: 'after_password_change'
526
+ get '/signups/confirmed', to: 'dashboards#show', as: 'after_signup'
527
+ get '/dashboard', to: 'dashboards#show', as: 'after_login'
528
+ get '/profile', to: 'profiles#show', as: 'after_password_change'
527
529
  ```
528
530
 
529
531
  ### I18n
@@ -51,7 +51,7 @@ module QuoVadis
51
51
  session.delete :account_pending_confirmation
52
52
 
53
53
  login account.model, true
54
- redirect_to qv.path_after_authentication, notice: QuoVadis.translate('flash.confirmation.confirmed')
54
+ redirect_to qv.path_after_signup, notice: QuoVadis.translate('flash.confirmation.confirmed')
55
55
  end
56
56
 
57
57
 
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module QuoVadis
4
- class Mailer < ::ActionMailer::Base
4
+ class Mailer < QuoVadis.mailer_superclass.constantize
5
5
 
6
6
  def reset_password
7
7
  @url = params[:url]
@@ -192,6 +192,13 @@ module QuoVadis
192
192
  Log.create account: account, action: action, ip: request.remote_ip, metadata: metadata
193
193
  end
194
194
 
195
+ def path_after_signup
196
+ return main_app.after_signup_path if main_app.respond_to?(:after_signup_path)
197
+ return main_app.after_login_path if main_app.respond_to?(:after_login_path)
198
+ return main_app.root_path if main_app.respond_to?(:root_path)
199
+ raise RuntimeError, 'Missing routes: after_signup_path, after_login_path, root_path; define at least one of them.'
200
+ end
201
+
195
202
  def path_after_authentication
196
203
  if (bookmark = rails_session[:qv_bookmark])
197
204
  rails_session.delete :qv_bookmark
@@ -10,6 +10,7 @@ QuoVadis.configure do
10
10
  password_reset_token_lifetime 10.minutes
11
11
  accounts_require_confirmation false
12
12
  account_confirmation_token_lifetime 10.minutes
13
+ mailer_superclass 'ApplicationMailer'
13
14
  mail_headers ({ from: 'Example App <support@example.com>' })
14
15
  enqueue_transactional_emails true
15
16
  app_name Rails.app_class.to_s.deconstantize # for the TOTP QR code
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module QuoVadis
4
- VERSION = '2.1.8'
4
+ VERSION = '2.1.10'
5
5
  end
data/lib/quo_vadis.rb CHANGED
@@ -25,6 +25,7 @@ module QuoVadis
25
25
  :session_lifetime_extend_to_end_of_day,# true | false
26
26
  :session_idle_timeout, # :lifetime | ActiveSupport::Duration | [integer] seconds
27
27
  :password_reset_token_lifetime, # ActiveSupport::Duration | [integer] seconds
28
+ :mailer_superclass, # string
28
29
  :mail_headers, # hash
29
30
  :accounts_require_confirmation, # true | false
30
31
  :account_confirmation_token_lifetime, # ActiveSupport::Duration | [integer] seconds
@@ -26,6 +26,11 @@ class SignUpsController < ApplicationController
26
26
  @user = User.find params[:id]
27
27
  end
28
28
 
29
+ def confirmed
30
+ # Here we could send an email.
31
+ redirect_to after_login_path
32
+ end
33
+
29
34
  private
30
35
 
31
36
  def user_params
@@ -0,0 +1,2 @@
1
+ class ApplicationMailer < ActionMailer::Base
2
+ end
@@ -1,5 +1,6 @@
1
1
  Rails.application.routes.draw do
2
2
  resources :users
3
+ get '/sign_ups/confirmed', to: 'sign_ups#confirmed', as: 'after_signup'
3
4
  resources :sign_ups
4
5
  resources :articles do
5
6
  collection do
@@ -33,6 +33,8 @@ class AccountConfirmationTest < IntegrationTest
33
33
  put action_path
34
34
 
35
35
  # verify logged in
36
+ assert_redirected_to '/sign_ups/confirmed'
37
+ follow_redirect!
36
38
  assert_redirected_to '/articles/secret'
37
39
  assert_equal 'Thanks for confirming your account. You are now logged in.', flash[:notice]
38
40
  assert controller.logged_in?
@@ -101,6 +103,8 @@ class AccountConfirmationTest < IntegrationTest
101
103
 
102
104
  put extract_path_from_email
103
105
 
106
+ assert_redirected_to '/sign_ups/confirmed'
107
+ follow_redirect!
104
108
  assert_redirected_to '/articles/secret'
105
109
  assert_equal 'Thanks for confirming your account. You are now logged in.', flash[:notice]
106
110
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quo_vadis
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.8
4
+ version: 2.1.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Stewart
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-06-18 00:00:00.000000000 Z
11
+ date: 2022-09-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -148,6 +148,7 @@ files:
148
148
  - test/dummy/app/controllers/articles_controller.rb
149
149
  - test/dummy/app/controllers/sign_ups_controller.rb
150
150
  - test/dummy/app/controllers/users_controller.rb
151
+ - test/dummy/app/mailers/application_mailer.rb
151
152
  - test/dummy/app/models/application_record.rb
152
153
  - test/dummy/app/models/article.rb
153
154
  - test/dummy/app/models/person.rb
@@ -224,7 +225,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
224
225
  - !ruby/object:Gem::Version
225
226
  version: '0'
226
227
  requirements: []
227
- rubygems_version: 3.2.22
228
+ rubygems_version: 3.2.33
228
229
  signing_key:
229
230
  specification_version: 4
230
231
  summary: Multifactor authentication for Rails 6 and 7.