Sha256: 40b799c12c13b764abdbb55d2cf7df3a50143ef02eb6e7950f974343ec5c080e

Contents?: true

Size: 867 Bytes

Versions: 16

Compression:

Stored size: 867 Bytes

Contents

module Doorkeeper
  class Application < ActiveRecord::Base
    include ApplicationMixin

    self.table_name = "#{table_name_prefix}oauth_applications#{table_name_suffix}".to_sym

    if ActiveRecord::VERSION::MAJOR >= 4
      has_many :authorized_tokens, -> { where(revoked_at: nil) }, class_name: 'AccessToken'
    else
      has_many :authorized_tokens, class_name: 'AccessToken', conditions: { revoked_at: nil }
    end
    has_many :authorized_applications, through: :authorized_tokens, source: :application

    def self.column_names_with_table
      self.column_names.map { |c| "#{table_name}.#{c}" }
    end

    def self.authorized_for(resource_owner)
      joins(:authorized_applications).
        where(AccessToken.table_name => { resource_owner_id: resource_owner.id, revoked_at: nil }).
        group(column_names_with_table.join(','))
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
doorkeeper-2.2.2 lib/doorkeeper/orm/active_record/application.rb
doorkeeper-3.0.0 lib/doorkeeper/orm/active_record/application.rb
doorkeeper-3.0.0.rc2 lib/doorkeeper/orm/active_record/application.rb
doorkeeper-3.0.0.rc1 lib/doorkeeper/orm/active_record/application.rb
doorkeeper-2.2.1 lib/doorkeeper/orm/active_record/application.rb
doorkeeper-2.2.0 lib/doorkeeper/orm/active_record/application.rb
doorkeeper-2.1.4 lib/doorkeeper/orm/active_record/application.rb
doorkeeper-2.1.3 lib/doorkeeper/orm/active_record/application.rb
doorkeeper-2.1.2 lib/doorkeeper/orm/active_record/application.rb
doorkeeper-2.1.1 lib/doorkeeper/orm/active_record/application.rb
doorkeeper-2.1.0 lib/doorkeeper/orm/active_record/application.rb
doorkeeper-2.0.1 lib/doorkeeper/orm/active_record/application.rb
doorkeeper-2.0.0 lib/doorkeeper/orm/active_record/application.rb
doorkeeper-2.0.0.rc3 lib/doorkeeper/orm/active_record/application.rb
doorkeeper-2.0.0.rc2 lib/doorkeeper/orm/active_record/application.rb
doorkeeper-2.0.0.alpha1 lib/doorkeeper/orm/active_record/application.rb