Sha256: e289e48b25d9615199ad3b34bb999a52a622a7fd4117d2d45a607732a17dc443
Contents?: true
Size: 1.16 KB
Versions: 4
Compression:
Stored size: 1.16 KB
Contents
class Devise::Oauth::Authorization < ActiveRecord::Base belongs_to :client, class_name: "Devise::Oauth::Client" belongs_to :resource_owner, class_name: Devise::Oauth.resource_owner validates :client_id, presence: true validates :resource_owner_id, presence: true before_create :generate_code before_create :create_expiration include Devise::Oauth::Scopable include Devise::Oauth::Blockable def expired?(at = Time.now) self.expires_at < at end def expire!(at = Time.now) self.expires_at = at save end def used!(at = Time.now) self.used_at = at save # TODO: May be we should destroy it instead? end def used? !!self.used_at end def valid_redirect_uri? uri if redirect_uri.blank? client.redirect_uris.include? uri else self.redirect_uri = uri end end def create_access_token Devise::Oauth::AccessToken.create client: client, resource_owner: resource_owner, scope: scope end private def generate_code self.code = Devise::Oauth.friendly_token end def create_expiration self.expires_at = Time.now + Devise::Oauth.authorization_code_expires_in end end
Version data entries
4 entries across 4 versions & 1 rubygems