1 class Oauth2Application < Doorkeeper::Application
2 belongs_to :owner, :polymorphic => true
4 validate :allowed_scopes
6 def authorized_scopes_for(user)
7 authorized_tokens.where(:resource_owner_id => user).sum(Doorkeeper::OAuth::Scopes.new, &:scopes)
13 return if owner.administrator?
15 errors.add(:scopes) if scopes.any? { |scope| Oauth::PRIVILEGED_SCOPES.include?(scope) }