quo_vadis 2.1.8 → 2.1.9

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: 3776f82ebb4987586131a44692de5891ec821e7e82a1de249fc3d8905ef551d8
4
+ data.tar.gz: 6914f2e05d50ffbd9451d6e50484674d7bb775d2d871922749cc4be1553e35a6
5
5
  SHA512:
6
- metadata.gz: e4e7c7bb2996556b35b153c56916aef9834dcac2abea08ede8becc14e030d8f4ea1444f9286c1ca9b728c1a13c16d8d9b2e701255d57b769c7dc9abefa84a976
7
- data.tar.gz: f466404a5ba44bfd506cbcd2fdc7b2f2d142ecab419363e3c368bb5eca67cfc78829afa698b8b0dc1cc76210b531a32a44c3bfdcd1ae709cf9eafe740861f089
6
+ metadata.gz: 5229c567fe09a76fad025b0dea0fc36192defd24e04077374816cfb99414b6a9cc3213e8410f5ee23fedb297d1b157d64345c317d646d1226655c5e60e50c1ac
7
+ data.tar.gz: 0ace7c8c5c1075eec8a54aa31ba01564a8a9ff0fec23387650a00a1721affca7c9326e083ac9f26a8afdd04bee6f6e8a748ae1c9bbf5b4e9d3b005804362afe6
data/CHANGELOG.md CHANGED
@@ -4,6 +4,11 @@
4
4
  ## HEAD
5
5
 
6
6
 
7
+ ## 2.1.9 (13 September 2022)
8
+
9
+ * Enable code to be run after sign up.
10
+
11
+
7
12
  ## 2.1.8 (18 June 2022)
8
13
 
9
14
  * Extract convenience method for has authentication account.
@@ -35,7 +40,7 @@
35
40
 
36
41
  ## 2.1.3 (30 September 2021)
37
42
 
38
- * Pass IP and timestamp as paramenters to mailer.
43
+ * Pass IP and timestamp as parameters to mailer.
39
44
 
40
45
 
41
46
  ## 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
 
@@ -518,12 +515,13 @@ end
518
515
 
519
516
  __Routes__
520
517
 
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:
518
+ 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
519
 
523
520
  ```ruby
524
521
  # config/routes.rb
525
- get '/dashboard', to: 'dashboards#show', as: 'after_login'
526
- get '/profile', to: 'profiles#show', as: 'after_password_change'
522
+ get '/signups/confirmed', to: 'dashboards#show', as: 'after_signup'
523
+ get '/dashboard', to: 'dashboards#show', as: 'after_login'
524
+ get '/profile', to: 'profiles#show', as: 'after_password_change'
527
525
  ```
528
526
 
529
527
  ### 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
 
@@ -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
@@ -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.9'
5
5
  end
@@ -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
@@ -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.9
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-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -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.2.22
227
+ rubygems_version: 3.2.33
228
228
  signing_key:
229
229
  specification_version: 4
230
230
  summary: Multifactor authentication for Rails 6 and 7.