Code Monkey home page Code Monkey logo

Comments (4)

toupeira avatar toupeira commented on July 19, 2024

@phlegx thanks for the report! I'm not sure if we already have access to Doorkeeper's configuration when that prepend call happens. 🤔

But the has_one association is defined at

has_one :openid_request,
class_name: 'Doorkeeper::OpenidConnect::Request',
inverse_of: :access_grant,
dependent: :delete
, so I think you should be able to replace your copy with prepend ::Doorkeeper::OpenidConnect::AccessGrant?

Let me know if that works and is an acceptable solution, and I'll add a note to the README similar to https://doorkeeper.gitbook.io/guides/configuration/models. We could also support include in addition to prepend to make it look more consistent.

from doorkeeper-openid_connect.

phlegx avatar phlegx commented on July 19, 2024

So, I should put prepend ::Doorkeeper::OpenidConnect::AccessGrant in my AccessGrant model instead of the has_one relation workaround?

from doorkeeper-openid_connect.

toupeira avatar toupeira commented on July 19, 2024

@phlegx yes, that should pull in the has_one definition and any other future changes (prepend acts similarly to include). Let me know if that works for you!

I was also curious now if we could just monkey-patch Doorkeeper::Orm::ActiveRecord::Mixins::AccessGrant rather than Doorkeeper::Orm::ActiveRecord::AccessGrant, but I couldn't find a way to inject code into the existing included block there (getting a ActiveSupport::Concern::MultipleIncludedBlocks error).

from doorkeeper-openid_connect.

jcdennen avatar jcdennen commented on July 19, 2024

Just adding a note here that I needed to specify:

    has_one :openid_request,
            class_name: 'Doorkeeper::OpenidConnect::Request',
            inverse_of: :access_grant,
            dependent:  :delete

and include foreign_key: 'access_grant_id' due to my team customizing the AccessGrant table_name. Without the foreign_key constraint specified, I received the following MySQL error:

Mysql2::Error: Unknown column 'oauth_openid_requests.{custom_table_name}_id' in 'where clause': SELECT  `oauth_openid_requests`.* FROM `oauth_openid_requests` WHERE `oauth_openid_requests`.`{custom_table_name}_id` = X LIMIT 1

The schema at this point had already been using access_grant_id as the column name. It may be useful to add this to the Doorkeeper custom model docs.

from doorkeeper-openid_connect.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.