Sha256: 2483d651346cdbf65daa4b19b280d53256f6a77cfa6ae6ed3207b9d79748e892

Contents?: true

Size: 1.04 KB

Versions: 4

Compression:

Stored size: 1.04 KB

Contents

module Sso
  class Client < ActiveRecord::Base
    include ::Sso::Logging

    belongs_to :session, class_name: 'Sso::Session', foreign_key: :sso_session_id
    belongs_to :application, class_name: 'Doorkeeper::Application',  inverse_of: :sso_clients
    belongs_to :access_grant, class_name: 'Doorkeeper::AccessGrant', inverse_of: :sso_client
    belongs_to :access_token, class_name: 'Doorkeeper::AccessToken', inverse_of: :sso_client

    validates :access_grant_id, uniqueness: { allow_nil: true }
    validates :access_token_id, uniqueness: { allow_nil: true }

    class << self
      def find_by_grant_token(token)
        find_by(access_grant: ::Doorkeeper::AccessGrant.by_token(token))
      end

      def find_by_access_token(token)
        find_by(access_token: ::Doorkeeper::AccessToken.by_token(token))
      end
    end

    def update_access_token(token)
      return false unless oauth_token = ::Doorkeeper::AccessToken.by_token(token)
      update(access_token_id: oauth_token.id, application_id: oauth_token.application.id)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
doorkeeper_sso-0.4.0 app/models/sso/client.rb
doorkeeper_sso-0.2.7 app/models/sso/client.rb
doorkeeper_sso-0.2.6 app/models/sso/client.rb
doorkeeper_sso-0.2.5 app/models/sso/client.rb