app/controllers/devise/oauth2/authorization.rb in devise_oauth2_rails4-2.1.0 vs app/controllers/devise/oauth2/authorization.rb in devise_oauth2_rails4-2.1.3
- old
+ new
@@ -3,16 +3,20 @@
module Authorization
extend ActiveSupport::Concern
def current_oauth2_client(opts: { secure: false })
return @secure_client ||= Client.find_by(secret: client_secret) if opts[:secure]
- return @secure_client ||= Client.find_by(id: current_access_token.client_id) if access_token?
+ return @secure_client ||= Client.find_by(id: current_access_token.client_id) if valid_access_token?
@client ||= Client.find_by('identifier = :client_id OR secret = :secret', client_id: client_id, secret: client_secret) if client_credentials?
end
def current_access_token
- @access_token ||= AccessToken.find_by(token: access_token)
+ @access_token ||= AccessToken.find_by(token: access_token) if accesss_token?
end
+
+ def valid_access_token?
+ !!current_access_token
+ end
def oauth2_client_signed_in?
!!@client
end