fix: resolve customAccessToken warning error that causes app to crash

In the present implementation verifyUserRelations(Model) sets a const hasManyTokens which seems to resolve to a boolean or undefined, so checking hasManyTokens.polymorphic throws an error.

It seems the intention is to check whether the the following conditions are met:
 1. a model has a hasMany accessTokens relation
 2. that relation is polymorphic

The proposed change should resolve correctly for any models that meet this criteria.
This commit is contained in:
ryanxwelch 2018-06-18 15:13:39 -04:00
parent c9913927e5
commit 778395e6d5
1 changed files with 1 additions and 1 deletions

View File

@ -460,7 +460,7 @@ app._verifyAuthModelRelations = function() {
const hasManyTokens = Model.relations && Model.relations.accessTokens;
// display a temp warning message for users using multiple users config
if (hasManyTokens.polymorphic) {
if (hasManyTokens && Model.settings.relations.accessTokens.polymorphic) {
console.warn(
'The app configuration follows the multiple user models setup ' +
'as described in http://ibm.biz/setup-loopback-auth',