lib/yao/token.rb in yao-0.2.11 vs lib/yao/token.rb in yao-0.2.12
- old
+ new
@@ -19,10 +19,11 @@
def register(token_data)
@token = token_data["id"]
@issued_at = Time.parse(token_data["issued_at"]).localtime
@expire_at = Time.parse(token_data["expires"]).localtime
+ Yao.current_tenant_id token_data["tenant"]["id"]
end
def expired?
return true unless self.expire_at
Time.now >= self.expire_at
@@ -33,11 +34,10 @@
res = cli.post('/v2.0/tokens') do |req|
req.body = auth_info.to_json
req.headers['Content-Type'] = 'application/json'
end
-
body = res.body["access"]
register(body["token"])
register_endpoints(body["serviceCatalog"])
self
@@ -56,7 +56,14 @@
@endpoints[type] = urls
end
Yao.default_client.register_endpoints(@endpoints, token: self)
end
+ end
+
+ def self.current_tenant_id(id=nil)
+ if id
+ @__tenant_id = id
+ end
+ @__tenant_id
end
end