uber_login 0.1.1 → 0.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 +12 -7
- data/spec/uber_login_spec.rb +40 -13
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MWU0YWFkMDg3NjA3MzFiM2QxN2Y3NmQzODBlOTFjMDIxZGY1YzliYg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZGYxZmFmZjA0ZGEzOGIzY2RmODVmODczOWQ5OTc0MzlmYTM5NGQ4NQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
Mzc4YWVjYzM0ZmQ5N2YyMDdlOWYxOTMzMjAwMDVlNmIwNzdiODk4YjRmNjQ4
|
10
|
+
ZDhhY2FmZjg1ZmIwZDA4MDQyNGVjMjExMTE1MGQxMDE3Zjg2ZTQ3NjllMzE4
|
11
|
+
OGJjMWEwMjhlZjM5ZjUzYWFhNDM1Y2NhOTM3ZDY5NjE4NzQ0ZGY=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
Mjc0NGNiMGM4ZmU3ZTEzNjExOWQ2NGU4M2QyODExYTNhNGJkYzEwNWU2N2Yz
|
14
|
+
ZGZiMWY2ZWVjZTU0MDY5MTRiNzk2YWM0NzEzNTZlMWJiNTdhOWI2YjQ0ZWYx
|
15
|
+
YTA5YTc2NTFmYmJkZTAyMDJhNDU5ZTc5MDc3NGVlM2UzNTU4MTI=
|
data/lib/uber_login/version.rb
CHANGED
data/lib/uber_login.rb
CHANGED
@@ -37,10 +37,14 @@ module UberLogin
|
|
37
37
|
# Clears session[:uid]
|
38
38
|
# If remember cookies were set they're cleared and the token is
|
39
39
|
# removed from the database.
|
40
|
-
def logout
|
41
|
-
|
42
|
-
|
43
|
-
|
40
|
+
def logout(sequence = nil)
|
41
|
+
if sequence
|
42
|
+
delete_from_database(sequence)
|
43
|
+
else
|
44
|
+
session.delete(:uid)
|
45
|
+
delete_from_database if cookies[:uid]
|
46
|
+
cookie_manager.clear
|
47
|
+
end
|
44
48
|
end
|
45
49
|
|
46
50
|
##
|
@@ -113,9 +117,10 @@ module UberLogin
|
|
113
117
|
end
|
114
118
|
|
115
119
|
##
|
116
|
-
# Removes a LoginToken with +uid+ and +sequence+
|
117
|
-
|
118
|
-
|
120
|
+
# Removes a LoginToken with current +uid+ and given +sequence+
|
121
|
+
# If +sequence+ is nil it is taken from the cookies.
|
122
|
+
def delete_from_database(sequence = nil)
|
123
|
+
sequence = sequence || cookie_manager.sequence
|
119
124
|
token = LoginToken.find_by(uid: cookies[:uid], sequence: sequence)
|
120
125
|
token.destroy
|
121
126
|
end
|
data/spec/uber_login_spec.rb
CHANGED
@@ -47,29 +47,56 @@ describe UberLogin do
|
|
47
47
|
end
|
48
48
|
|
49
49
|
describe '#logout' do
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
50
|
+
context 'sequence is nil' do
|
51
|
+
it 'deletes session[:uid]' do
|
52
|
+
controller.login(user)
|
53
|
+
controller.logout
|
54
|
+
expect(session[:uid]).to be_nil
|
55
|
+
end
|
56
|
+
|
57
|
+
context 'persistent login was made' do
|
58
|
+
before { controller.login(user, true) }
|
59
|
+
|
60
|
+
it 'deletes session[:uid]' do
|
61
|
+
controller.logout
|
62
|
+
expect(session[:uid]).to be_nil
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'deletes login cookies' do
|
66
|
+
controller.logout
|
67
|
+
expect(cookies[:uid]).to be_nil
|
68
|
+
expect(cookies[:ulogin]).to be_nil
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'deletes a LoginToken row' do
|
72
|
+
expect {
|
73
|
+
controller.logout
|
74
|
+
}.to change{ LoginToken.count }.by -1
|
75
|
+
end
|
76
|
+
end
|
54
77
|
end
|
55
78
|
|
56
|
-
context '
|
79
|
+
context 'sequence is not nil' do
|
57
80
|
before { controller.login(user, true) }
|
58
81
|
|
59
|
-
it '
|
60
|
-
controller.logout
|
61
|
-
expect(session[:uid]).
|
82
|
+
it 'does not clear session[:uid]' do
|
83
|
+
controller.logout('sequence')
|
84
|
+
expect(session[:uid]).to_not be_nil
|
62
85
|
end
|
63
86
|
|
64
|
-
it '
|
65
|
-
controller.logout
|
66
|
-
expect(cookies[:uid]).
|
67
|
-
|
87
|
+
it 'does not clear cookies[:uid]' do
|
88
|
+
controller.logout('sequence')
|
89
|
+
expect(cookies[:uid]).to_not be_nil
|
90
|
+
end
|
91
|
+
|
92
|
+
it 'does not clear cookies[:ulogin]' do
|
93
|
+
controller.logout('sequence')
|
94
|
+
expect(cookies[:ulogin]).to_not be_nil
|
68
95
|
end
|
69
96
|
|
70
97
|
it 'deletes a LoginToken row' do
|
71
98
|
expect {
|
72
|
-
controller.logout
|
99
|
+
controller.logout('sequence')
|
73
100
|
}.to change{ LoginToken.count }.by -1
|
74
101
|
end
|
75
102
|
end
|