Skip to content

Commit

Permalink
Make verifyUserRelations() more robust
Browse files Browse the repository at this point in the history
The fix introduced in previous commit was relying on the default
merge algorighm applied when a child model inherits relation config
from the parent.

This commit changes the check to use a more reliable approach
based on the relation metadata configured by the child model.
  • Loading branch information
mcitdev authored and bajtos committed Jul 3, 2018
1 parent cd1b319 commit f9e9aaa
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions lib/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -497,19 +497,19 @@ app._verifyAuthModelRelations = function() {
function verifyUserRelations(Model) {
const hasManyTokens = Model.relations && Model.relations.accessTokens;

const relationsConfig = Model.settings.relations || {};
const hasPolyMorphicTokens = (relationsConfig.accessTokens || {}).polymorphic;
// display a temp warning message for users using multiple users config
if (hasPolyMorphicTokens) {
console.warn(
'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.');
if (hasManyTokens) {
// display a temp warning message for users using multiple users config
if (hasManyTokens.polymorphic) {
console.warn(
'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.');
}
return;
}

if (hasManyTokens) return;

const relationsConfig = Model.settings.relations || {};
const accessTokenName = (relationsConfig.accessTokens || {}).model;
if (accessTokenName) {
console.warn(
Expand Down

0 comments on commit f9e9aaa

Please sign in to comment.