lib/rack/oauth2/models/auth_request.rb in rack-oauth2-server-1.1.1 vs lib/rack/oauth2/models/auth_request.rb in rack-oauth2-server-1.2.0
- old
+ new
@@ -56,20 +56,16 @@
def grant!(identity)
raise ArgumentError, "Must supply a identity" unless identity
return if revoked
self.authorized_at = Time.now.utc
if response_type == "code" # Requested authorization code
- unless self.grant_code
- access_grant = AccessGrant.create(identity, scope, client_id, redirect_uri)
- self.grant_code = access_grant.code
- self.class.collection.update({ :_id=>id, :revoked=>nil }, { :$set=>{ :grant_code=>access_grant.code, :authorized_at=>authorized_at } })
- end
+ access_grant = AccessGrant.create(identity, scope, client_id, redirect_uri)
+ self.grant_code = access_grant.code
+ self.class.collection.update({ :_id=>id, :revoked=>nil }, { :$set=>{ :grant_code=>access_grant.code, :authorized_at=>authorized_at } })
else # Requested access token
- unless self.access_token
- access_token = AccessToken.get_token_for(identity, scope, client_id)
- self.access_token = access_token.token
- self.class.collection.update({ :_id=>id, :revoked=>nil, :access_token=>nil }, { :$set=>{ :access_token=>access_token.token, :authorized_at=>authorized_at } })
- end
+ access_token = AccessToken.get_token_for(identity, scope, client_id)
+ self.access_token = access_token.token
+ self.class.collection.update({ :_id=>id, :revoked=>nil, :access_token=>nil }, { :$set=>{ :access_token=>access_token.token, :authorized_at=>authorized_at } })
end
true
end
# Deny access.