quo_vadis 2.3.1 → 2.4.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/CHANGELOG.md +6 -0
- data/README.md +2 -1
- data/app/controllers/quo_vadis/sessions_controller.rb +3 -0
- data/lib/quo_vadis/controller.rb +15 -8
- data/lib/quo_vadis/version.rb +1 -1
- data/test/integration/password_login_test.rb +12 -0
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 49fe683373a68bb0b0dad55449c2501db61d8a270458d82816cc98d48dc3e8a7
|
|
4
|
+
data.tar.gz: d0105c2814b6b81330e215f644bc86df9a2fc38953e00a765e6b4c13e411cb23
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 881a22e6d2d2b6a54cc609f57c37ece92d4f6a74ae35dafce2cd057dd98822324d02a6fdfe68f496c85189a241ff3d282fea7adf48746ea4805cfddd18af9580
|
|
7
|
+
data.tar.gz: b960cd5f39665341e1caaedaa13aaa0f05f08006afe704897d5fb2c87c8ac3078a1e18f851ba45739b9778faa2f03066655b4e53ea0f3be5a55647b5fd319a4c
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
|
@@ -251,7 +251,8 @@ If you do not include a `remember` checkbox, the user will be logged in for `Quo
|
|
|
251
251
|
|
|
252
252
|
After authenticating the user will be redirected to the first of these that exists:
|
|
253
253
|
|
|
254
|
-
- the page
|
|
254
|
+
- the page specified in the `return` URL parameter when requesting the login page;
|
|
255
|
+
- the page (requiring authentication) they tried to view before they were redirected to the login page;
|
|
255
256
|
- a route named `after_login`, if any;
|
|
256
257
|
- your root route.
|
|
257
258
|
|
data/lib/quo_vadis/controller.rb
CHANGED
|
@@ -15,6 +15,10 @@ module QuoVadis
|
|
|
15
15
|
|
|
16
16
|
base.before_action { CurrentRequestDetails.request = request }
|
|
17
17
|
|
|
18
|
+
base.before_action { |controller|
|
|
19
|
+
controller.qv.require_confirmation unless controller.class == QuoVadis::ConfirmationsController
|
|
20
|
+
}
|
|
21
|
+
|
|
18
22
|
base.helper_method :authenticated_model, :logged_in?
|
|
19
23
|
|
|
20
24
|
# Remember the last activity time so we can timeout idle sessions.
|
|
@@ -31,14 +35,7 @@ module QuoVadis
|
|
|
31
35
|
|
|
32
36
|
|
|
33
37
|
def require_password_authentication
|
|
34
|
-
if logged_in?
|
|
35
|
-
if QuoVadis.accounts_require_confirmation && !authenticated_model.qv_account.confirmed?
|
|
36
|
-
qv.request_confirmation authenticated_model
|
|
37
|
-
session[:qv_bookmark] = request.original_fullpath
|
|
38
|
-
redirect_to quo_vadis.confirm_path
|
|
39
|
-
end
|
|
40
|
-
return
|
|
41
|
-
end
|
|
38
|
+
return if logged_in?
|
|
42
39
|
session[:qv_bookmark] = request.original_fullpath
|
|
43
40
|
redirect_to quo_vadis.login_path, notice: QuoVadis.translate('flash.require_authentication')
|
|
44
41
|
end
|
|
@@ -156,6 +153,16 @@ module QuoVadis
|
|
|
156
153
|
old_session.each { |k,v| rails_session[k] = v }
|
|
157
154
|
end
|
|
158
155
|
|
|
156
|
+
def require_confirmation
|
|
157
|
+
return if ! QuoVadis.accounts_require_confirmation
|
|
158
|
+
return if ! controller.logged_in?
|
|
159
|
+
return if controller.authenticated_model.qv_account.confirmed?
|
|
160
|
+
|
|
161
|
+
request_confirmation controller.authenticated_model
|
|
162
|
+
rails_session[:qv_bookmark] = controller.request.original_fullpath
|
|
163
|
+
controller.redirect_to controller.quo_vadis.confirm_path
|
|
164
|
+
end
|
|
165
|
+
|
|
159
166
|
def request_confirmation(model)
|
|
160
167
|
rails_session[:account_pending_confirmation] = model.qv_account.id
|
|
161
168
|
|
data/lib/quo_vadis/version.rb
CHANGED
|
@@ -42,6 +42,18 @@ class PasswordLoginTest < IntegrationTest
|
|
|
42
42
|
end
|
|
43
43
|
|
|
44
44
|
|
|
45
|
+
test 'successful login redirect page can be overridden' do
|
|
46
|
+
get quo_vadis.login_path(return: "/articles")
|
|
47
|
+
refute_nil session[:qv_bookmark]
|
|
48
|
+
|
|
49
|
+
User.create! name: 'bob', email: 'bob@example.com', password: '123456789abc'
|
|
50
|
+
post quo_vadis.login_path(email: 'bob@example.com', password: '123456789abc')
|
|
51
|
+
|
|
52
|
+
assert_redirected_to articles_path
|
|
53
|
+
assert_nil session[:qv_bookmark]
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
|
|
45
57
|
test 'failed login' do
|
|
46
58
|
User.create! name: 'bob', email: 'bob@example.com', password: '123456789abc'
|
|
47
59
|
post quo_vadis.login_path(email: 'bob@example.com', password: 'wrong')
|