Skip to content

Role.isOwner() does not support polymorphic belongsTo relations to multiple User models #3644

@lehni

Description

@lehni

Description/Steps to reproduce

See this comment by @ebarault outlining the problem and how to reproduce it by activating a currently skipped test in multiple-user-principal-types.test.js:

This test currently fails, see the inlined comments, support for polymorphic belongsTo should be added to isOwner() to solve this issue.
I shook my head for almost an hour on this, trying to find a solution as-is or wondering if it could just be solved at all, before realizing this was a design issue. Using standard belongsTo relations between persisted models and user when using multiple user models in an app just won't do it, expect under particular circumstances.

Let's address belongsTo + polymorphic in a follow-up PR.
I marked the faulty tests as skipped to keep track

Link to reproduction sandbox

Simply activate this test by changing it.skip to it here:

it.skip('resolves the owner using the corrent belongsTo relation',

Expected result

The owner should be resolved using the correct belongsTo relation

Additional information

Related issues:

I believe as of v3.14.0, this situation is now triggering the following warning on the console:

The app configuration follows the multiple user models setup as described in http://ibm.biz/setup-loopback-auth The built-in role resolver $owner is not currently compatible with this configuration and should not be used in production

Once this issue is resolved, this warning can be removed.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions