Module: OAuth2::Provider::Models::Authorization

Extended by:
ActiveSupport::Concern
Defined in:
lib/oauth2/provider/models/authorization.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#has_scope?(s) ⇒ Boolean


11
12
13
# File 'lib/oauth2/provider/models/authorization.rb', line 11

def has_scope?(s)
  scope && scope.split(" ").include?(s)
end

#resource_ownerObject


26
27
28
# File 'lib/oauth2/provider/models/authorization.rb', line 26

def resource_owner
  resource_owner_id && resource_owner_class.find(resource_owner_id)
end

#resource_owner=(ro) ⇒ Object


21
22
23
24
# File 'lib/oauth2/provider/models/authorization.rb', line 21

def resource_owner=(ro)
  self.resource_owner_id = ro && ro.id
  self.resource_owner_type = ro && ro.class.name
end

#resource_owner_classObject


30
31
32
# File 'lib/oauth2/provider/models/authorization.rb', line 30

def resource_owner_class
  resource_owner_type.constantize
end

#revokeObject


15
16
17
18
19
# File 'lib/oauth2/provider/models/authorization.rb', line 15

def revoke
  authorization_codes.destroy_all
  access_tokens.destroy_all
  destroy
end