Make verifyUserRelations() more robust
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.
This commit is contained in:
parent
cd1b31920e
commit
f9e9aaa8ce
|
@ -497,19 +497,19 @@ app._verifyAuthModelRelations = function() {
|
||||||
function verifyUserRelations(Model) {
|
function verifyUserRelations(Model) {
|
||||||
const hasManyTokens = Model.relations && Model.relations.accessTokens;
|
const hasManyTokens = Model.relations && Model.relations.accessTokens;
|
||||||
|
|
||||||
const relationsConfig = Model.settings.relations || {};
|
if (hasManyTokens) {
|
||||||
const hasPolyMorphicTokens = (relationsConfig.accessTokens || {}).polymorphic;
|
|
||||||
// display a temp warning message for users using multiple users config
|
// display a temp warning message for users using multiple users config
|
||||||
if (hasPolyMorphicTokens) {
|
if (hasManyTokens.polymorphic) {
|
||||||
console.warn(
|
console.warn(
|
||||||
'The app configuration follows the multiple user models setup ' +
|
'The app configuration follows the multiple user models setup ' +
|
||||||
'as described in http://ibm.biz/setup-loopback-auth',
|
'as described in http://ibm.biz/setup-loopback-auth',
|
||||||
'The built-in role resolver $owner is not currently compatible ' +
|
'The built-in role resolver $owner is not currently compatible ' +
|
||||||
'with this configuration and should not be used in production.');
|
'with this configuration and should not be used in production.');
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (hasManyTokens) return;
|
const relationsConfig = Model.settings.relations || {};
|
||||||
|
|
||||||
const accessTokenName = (relationsConfig.accessTokens || {}).model;
|
const accessTokenName = (relationsConfig.accessTokens || {}).model;
|
||||||
if (accessTokenName) {
|
if (accessTokenName) {
|
||||||
console.warn(
|
console.warn(
|
||||||
|
|
Loading…
Reference in New Issue