uber_login 2.1.0 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/uber_login/version.rb +1 -1
- data/lib/uber_login.rb +8 -0
- data/spec/uber_login_spec.rb +47 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZGRhZTQ5MjJjMDllYzc1NWIyZGVlZDA5MzczZmMwYjA2YjJkMGZhNw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MTdjMjU4OTM5ZGM2ZWE0NGFiZjcwZTU1ZGY0MGFjYzYzMGUxZDM4OA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZmUxY2NmOWZkMTYwNDAxZjYyMzEwMTkxMzgwZmQ2MGZlMzNjZTNlMDhhYzJh
|
10
|
+
MDE0NTAzMjlkZGE5MjIwMzdjODJlMGRlMGQxNGYzN2Y2Yjk1NWY4ZjY0YTcw
|
11
|
+
ODNjZmVjYzVkNDAxMGE3ZDE0YWRlZGJlMDcyYWI5ZjU4MWU3M2M=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YjU3MjE4MzkzNGI0NmM3N2FlNjcwN2QxNTJjYmJhODQ2NGQwMDgyN2ExMWEy
|
14
|
+
YTI1NWNmNjljYjNiM2QxYTBlMDk4NmRmZjJkZTZhZTUzZmRjZWY2MjM2OWQ3
|
15
|
+
NDJjNWY4YmZkYzM1MTI2ZWZlYjhkMTQ0MjdjMmQwODBkNDA0YWE=
|
data/lib/uber_login/version.rb
CHANGED
data/lib/uber_login.rb
CHANGED
@@ -13,6 +13,7 @@ module UberLogin
|
|
13
13
|
|
14
14
|
included do
|
15
15
|
define_callbacks :login, :logout
|
16
|
+
@login_from_cookies = nil
|
16
17
|
end
|
17
18
|
|
18
19
|
##
|
@@ -41,6 +42,7 @@ module UberLogin
|
|
41
42
|
# If strong sessions are enabled session[+:ulogin+] is set to the same value that cookies[+:ulogin+] would have
|
42
43
|
def login(user, remember = false)
|
43
44
|
logout_all unless UberLogin.configuration.allow_multiple_login
|
45
|
+
@login_from_cookies = false
|
44
46
|
|
45
47
|
run_callbacks :login do
|
46
48
|
if strong_sessions or remember
|
@@ -80,6 +82,10 @@ module UberLogin
|
|
80
82
|
cookie_manager.clear
|
81
83
|
end
|
82
84
|
|
85
|
+
def login_from_cookies?
|
86
|
+
@login_from_cookies
|
87
|
+
end
|
88
|
+
|
83
89
|
def persistent_login?
|
84
90
|
cookie_manager.valid?
|
85
91
|
end
|
@@ -108,6 +114,8 @@ module UberLogin
|
|
108
114
|
# Attempts a login from the +:uid+ and +:ulogin+ cookies.
|
109
115
|
def login_from_cookies
|
110
116
|
if persistent_login?
|
117
|
+
@login_from_cookies = true
|
118
|
+
|
111
119
|
run_callbacks :login do
|
112
120
|
reset_session
|
113
121
|
session[:uid] = cookies[:uid]
|
data/spec/uber_login_spec.rb
CHANGED
@@ -317,4 +317,51 @@ describe UberLogin do
|
|
317
317
|
end
|
318
318
|
end
|
319
319
|
end
|
320
|
+
|
321
|
+
describe '#login_from_cookies?' do
|
322
|
+
context 'cookies are not set' do
|
323
|
+
context 'session is not set' do
|
324
|
+
context 'after a login' do
|
325
|
+
it 'be false' do
|
326
|
+
controller.login(user)
|
327
|
+
expect(controller.login_from_cookies?).to be_false
|
328
|
+
end
|
329
|
+
end
|
330
|
+
|
331
|
+
context 'other pages' do
|
332
|
+
it 'is nil' do
|
333
|
+
expect(controller.login_from_cookies?).to be_nil
|
334
|
+
end
|
335
|
+
end
|
336
|
+
end
|
337
|
+
end
|
338
|
+
|
339
|
+
context 'cookies[:uid] and cookies[:ulogin] are set' do
|
340
|
+
before {
|
341
|
+
cookies[:uid] = "100"
|
342
|
+
cookies[:ulogin] = "whatever:beef"
|
343
|
+
session[:uid] = nil
|
344
|
+
}
|
345
|
+
|
346
|
+
context 'the cookies are valid' do
|
347
|
+
before { UberLogin::CookieManager.any_instance.stub(:valid?).and_return true }
|
348
|
+
|
349
|
+
context 'on cookie login' do
|
350
|
+
it 'is true' do
|
351
|
+
controller.current_user
|
352
|
+
expect(controller.login_from_cookies?).to be_true
|
353
|
+
end
|
354
|
+
end
|
355
|
+
end
|
356
|
+
|
357
|
+
context 'the cookies are not valid' do
|
358
|
+
before { UberLogin::CookieManager.any_instance.stub(:valid?).and_return false }
|
359
|
+
|
360
|
+
it 'is nil' do
|
361
|
+
controller.current_user
|
362
|
+
expect(controller.login_from_cookies?).to be_nil
|
363
|
+
end
|
364
|
+
end
|
365
|
+
end
|
366
|
+
end
|
320
367
|
end
|