lib/doorkeeper/oauth/authorization/token.rb in doorkeeper-2.2.0 vs lib/doorkeeper/oauth/authorization/token.rb in doorkeeper-2.2.1
- old
+ new
@@ -7,16 +7,13 @@
def initialize(pre_auth, resource_owner)
@pre_auth = pre_auth
@resource_owner = resource_owner
end
- def self.access_token_expires_in(server, pre_auth)
- custom_expiration = server.
- custom_access_token_expires_in.call(pre_auth)
-
- if custom_expiration
- custom_expiration
+ def self.access_token_expires_in(server, pre_auth_or_oauth_client)
+ if expiration = custom_expiration(server, pre_auth_or_oauth_client)
+ expiration
else
server.access_token_expires_in
end
end
@@ -34,9 +31,21 @@
{
controller: 'doorkeeper/token_info',
action: :show,
access_token: token.token
}
+ end
+
+ private
+
+ def self.custom_expiration(server, pre_auth_or_oauth_client)
+ oauth_client = if pre_auth_or_oauth_client.respond_to?(:client)
+ pre_auth_or_oauth_client.client
+ else
+ pre_auth_or_oauth_client
+ end
+
+ server.custom_access_token_expires_in.call(oauth_client)
end
def configuration
Doorkeeper.configuration
end