cow_auth 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cow_auth/user.rb +9 -1
- data/lib/cow_auth/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dff8fe9127d7933119a7bc9e1a394b63459347b8
|
4
|
+
data.tar.gz: 044fe42d8ab52301dcb26d555b2249a2e361469b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6470c86664faba0fa3e5900666cb3222a91b2516331809d642f3c6398317ed5a9814be3e8eab0aadb188a0387ff7254ca81f3757bc58566e5af834d384f44a75
|
7
|
+
data.tar.gz: ce090243601ce2a58903a1881419837be92c0edb65b6681f5459c900c7baf7823d66d3eb118ed877d35b705712090898b3d58483c9617533ebcce5c06fb629f8
|
data/lib/cow_auth/user.rb
CHANGED
@@ -30,7 +30,7 @@ module CowAuth
|
|
30
30
|
def api_sign_in
|
31
31
|
User.assert_redis_handle_present
|
32
32
|
$redis.set(self.redis_key, {
|
33
|
-
auth_token: User.generate_auth_token,
|
33
|
+
auth_token: self.token_valid? ? self.auth_token : User.generate_auth_token,
|
34
34
|
expires_at: User.generate_token_expires_at
|
35
35
|
}.to_json)
|
36
36
|
end
|
@@ -62,6 +62,14 @@ module CowAuth
|
|
62
62
|
return "user_#{self.sid}"
|
63
63
|
end
|
64
64
|
|
65
|
+
def token_valid?
|
66
|
+
api_key = User.fetch_api_key_from_redis(self.sid)
|
67
|
+
return api_key.present? &&
|
68
|
+
api_key.key?(:auth_token) &&
|
69
|
+
api_key.key?(:expires_at) &&
|
70
|
+
api_key[:expires_at] > Time.zone.now
|
71
|
+
end
|
72
|
+
|
65
73
|
private
|
66
74
|
|
67
75
|
def generate_sid_if_necessary
|
data/lib/cow_auth/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cow_auth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mickey Cowden
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-06-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -127,7 +127,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
127
127
|
version: '0'
|
128
128
|
requirements: []
|
129
129
|
rubyforge_project:
|
130
|
-
rubygems_version: 2.6.
|
130
|
+
rubygems_version: 2.6.12
|
131
131
|
signing_key:
|
132
132
|
specification_version: 4
|
133
133
|
summary: Authentication gem
|