Class: WeixinAuthorize::RedisStorage
- Inherits:
-
Storage
- Object
- Storage
- WeixinAuthorize::RedisStorage
show all
- Defined in:
- lib/weixin_authorize/adapter/redis_storage.rb
Instance Attribute Summary
Attributes inherited from Storage
#client
Instance Method Summary
collapse
Methods inherited from Storage
#authenticate_headers, #http_get_access_token, init_with, #initialize, #set_access_token_for_client
Instance Method Details
#access_token ⇒ Object
22
23
24
25
26
27
|
# File 'lib/weixin_authorize/adapter/redis_storage.rb', line 22
def access_token
super
client.access_token = weixin_redis.hget(client.redis_key, "access_token")
client.expired_at = weixin_redis.hget(client.redis_key, "expired_at")
client.access_token
end
|
#authenticate ⇒ Object
15
16
17
18
19
20
|
# File 'lib/weixin_authorize/adapter/redis_storage.rb', line 15
def authenticate
super
weixin_redis.hmset(client.redis_key, :access_token, client.access_token,
:expired_at, client.expired_at)
weixin_redis.expireat(client.redis_key, client.expired_at.to_i-10) end
|
#token_expired? ⇒ Boolean
11
12
13
|
# File 'lib/weixin_authorize/adapter/redis_storage.rb', line 11
def token_expired?
weixin_redis.hvals(client.redis_key).empty?
end
|
#valid? ⇒ Boolean
6
7
8
9
|
# File 'lib/weixin_authorize/adapter/redis_storage.rb', line 6
def valid?
weixin_redis.del(client.redis_key)
super
end
|
#weixin_redis ⇒ Object
29
30
31
|
# File 'lib/weixin_authorize/adapter/redis_storage.rb', line 29
def weixin_redis
WeixinAuthorize.config.redis
end
|