Class: Oauth2Provider::OauthAuthorization

Inherits:
Object
  • Object
show all
Includes:
Mongoid::Document, Mongoid::Timestamps
Defined in:
app/models/oauth2_provider/oauth_authorization.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.block_access!(client_uri, resource_owner_uri) ⇒ Object

Block tokens used from a client in behalf of a resource owner



34
35
36
# File 'app/models/oauth2_provider/oauth_authorization.rb', line 34

def self.block_access!(client_uri, resource_owner_uri)
  self.where(client_uri: client_uri, resource_owner_uri: resource_owner_uri).map(&:block!)
end

.block_client!(client_uri) ⇒ Object

Block tokens used from a client



29
30
31
# File 'app/models/oauth2_provider/oauth_authorization.rb', line 29

def self.block_client!(client_uri)
  self.where(client_uri: client_uri).map(&:block!)
end

.where_code_and_client_uri(code, client_id) ⇒ Object



51
52
53
# File 'app/models/oauth2_provider/oauth_authorization.rb', line 51

def where_code_and_client_uri(code, client_id)
  where(code: code).where(client_uri: client_id)
end

Instance Method Details

#block!Object

Block the authorization (when resource owner blocks a client)



23
24
25
26
# File 'app/models/oauth2_provider/oauth_authorization.rb', line 23

def block!
  self.blocked = Time.now
  self.save
end

#blocked?Boolean

Check if the status is or is not blocked

Returns:

  • (Boolean)


39
40
41
# File 'app/models/oauth2_provider/oauth_authorization.rb', line 39

def blocked?
  !self.blocked.nil?
end

#expired?Boolean

Check if the authorization is expired

Returns:

  • (Boolean)


44
45
46
# File 'app/models/oauth2_provider/oauth_authorization.rb', line 44

def expired?
  self.expire_at < Time.now
end