lib/rack/oauth2/models/auth_request.rb in rack-oauth2-server-1.2.2 vs lib/rack/oauth2/models/auth_request.rb in rack-oauth2-server-1.3.0

- old
+ new

@@ -16,11 +16,12 @@ # Create a new authorization request. This holds state, so in addition # to client ID and scope, we need to know the URL to redirect back to # and any state value to pass back in that redirect. def create(client_id, scope, redirect_uri, response_type, state) fields = { :client_id=>BSON::ObjectId(client_id.to_s), :scope=>scope, :redirect_uri=>redirect_uri, :state=>state, - :response_type=>response_type, :created_at=>Time.now.utc, :grant_code=>nil, :authorized_at=>nil, :revoked=>nil } + :response_type=>response_type, :created_at=>Time.now.utc.to_i, :grant_code=>nil, + :authorized_at=>nil, :revoked=>nil } fields[:_id] = collection.insert(fields) Server.new_instance self, fields end def collection @@ -54,11 +55,11 @@ # Grant access to the specified identity. def grant!(identity) raise ArgumentError, "Must supply a identity" unless identity return if revoked - self.authorized_at = Time.now.utc + self.authorized_at = Time.now.utc.to_i if response_type == "code" # Requested authorization 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 } }) else # Requested access token @@ -69,10 +70,10 @@ true end # Deny access. def deny! - self.authorized_at = Time.now.utc + self.authorized_at = Time.now.utc.to_i self.class.collection.update({ :_id=>id }, { :$set=>{ :authorized_at=>authorized_at } }) end Server.create_indexes do # Used to revoke all pending access grants when revoking client.