Sha256: 5ad83edf08c24abe66454c6125efe45ef4f442d5a696d6cf8b373bbf14bc7e00
Contents?: true
Size: 937 Bytes
Versions: 1
Compression:
Stored size: 937 Bytes
Contents
module Doorkeeper class Application < ActiveRecord::Base self.table_name = :oauth_applications has_many :authorized_tokens, :class_name => "AccessToken", :conditions => { :revoked_at => nil } has_many :authorized_applications, :through => :authorized_tokens, :source => :application def self.column_names_with_table self.column_names.map { |c| "#{self.table_name}.#{c}" } end def self.authorized_for(resource_owner) # SELECT "oauth_access_tokens".* FROM "oauth_access_tokens" WHERE "oauth_access_tokens"."application_id" = 5 # AND "oauth_access_tokens"."resource_owner_id" = 45 AND "oauth_access_tokens "."revoked_at" IS NULL ORDER BY created_at desc LIMIT 1 joins(:authorized_applications). where(:oauth_access_tokens => { :resource_owner_id => resource_owner.id, :revoked_at => nil }). group(column_names_with_table.join(',')) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
couchkeeper-0.6.7 | lib/doorkeeper/models/active_record/application.rb |