refactor fix: default empty object before polymorphic check

Per @bajtos recommendation
https://github.com/strongloop/loopback/pull/3921#issuecomment-398307719
This commit is contained in:
ryanxwelch 2018-06-19 12:56:17 -04:00
parent 778395e6d5
commit c5cf2f1e05
1 changed files with 3 additions and 3 deletions

View File

@ -458,9 +458,10 @@ 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 (hasManyTokens && Model.settings.relations.accessTokens.polymorphic) {
if (hasPolyMorphicTokens) {
console.warn(
'The app configuration follows the multiple user models setup ' +
'as described in http://ibm.biz/setup-loopback-auth',
@ -470,7 +471,6 @@ app._verifyAuthModelRelations = function() {
if (hasManyTokens) return;
const relationsConfig = Model.settings.relations || {};
const accessTokenName = (relationsConfig.accessTokens || {}).model;
if (accessTokenName) {
console.warn(