2018-07-25 05:30:33 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-12-09 12:36:50 -05:00
|
|
|
class OauthAccessToken < Doorkeeper::AccessToken
|
2016-04-13 01:39:18 -04:00
|
|
|
belongs_to :resource_owner, class_name: 'User'
|
|
|
|
belongs_to :application, class_name: 'Doorkeeper::Application'
|
2017-09-27 09:56:48 -04:00
|
|
|
|
2017-10-30 13:49:46 -04:00
|
|
|
alias_attribute :user, :resource_owner
|
|
|
|
|
2019-09-09 20:05:55 -04:00
|
|
|
scope :distinct_resource_owner_counts, ->(applications) { where(application: applications).distinct.group(:application_id).count(:resource_owner_id) }
|
|
|
|
|
2017-10-30 13:49:46 -04:00
|
|
|
def scopes=(value)
|
|
|
|
if value.is_a?(Array)
|
|
|
|
super(Doorkeeper::OAuth::Scopes.from_array(value).to_s)
|
|
|
|
else
|
|
|
|
super
|
|
|
|
end
|
|
|
|
end
|
2016-04-13 01:39:18 -04:00
|
|
|
end
|