]> git.openstreetmap.org Git - rails.git/commitdiff
Treat association between users and OAuth 2 applications as polymorphic
authorTom Hughes <tom@compton.nu>
Wed, 21 Jul 2021 10:52:10 +0000 (11:52 +0100)
committerTom Hughes <tom@compton.nu>
Wed, 21 Jul 2021 10:52:10 +0000 (11:52 +0100)
app/models/user.rb

index c02795a4af9656f4e8219d15dd942ab54e27a26c..cca894a6bf291e54e5a3424c51e8ebcfa8374d9b 100644 (file)
@@ -68,7 +68,7 @@ class User < ApplicationRecord
   has_many :client_applications
   has_many :oauth_tokens, -> { order(:authorized_at => :desc).preload(:client_application) }, :class_name => "OauthToken"
 
-  has_many :oauth2_applications, :class_name => Doorkeeper.config.application_model.name, :foreign_key => :owner_id
+  has_many :oauth2_applications, :class_name => Doorkeeper.config.application_model.name, :as => :owner
   has_many :access_grants, :class_name => Doorkeeper.config.access_grant_model.name, :foreign_key => :resource_owner_id
   has_many :access_tokens, :class_name => Doorkeeper.config.access_token_model.name, :foreign_key => :resource_owner_id