Loopback extending User model throws TypeError: Cannot convert undefined or null to object

Loopback extending User model throws TypeError: Cannot convert undefined or null to object

我正在尝试按如下方式扩展默认用户模型:

我使用 slc loopback:model cli 命令创建了新的 'account' 模型(使用 firstName 和 lastName 属性 扩展了内置的 User 模型)。它创建了一个 common/models/account.json:

{
  "name": "account",
  "base": "User",
  "idInjection": true,
  "options": {
    "validateUpsert": true
  },
  "properties": {
    "firstName": {
      "type": "string"
    },
    "lastName": {
      "type": "string"
    }
  },
  "validations": [],
  "relations": {},
  "acls": [],
  "methods": {}
}

和一个common/models/account.js:

'use strict';

module.exports = function(Account) {

}; 

也添加到 server/model-config.json:

  "account": {
    "dataSource": "db",
    "public": true
  }

当我尝试登录新的 url 时,我遇到了 500 错误,而不是 401:

Unhandled error for request POST /api/accounts/login: TypeError: Cannot convert undefined or null to object
    at Function.keys (<anonymous>)
    at Memory._findAllSkippingIncludes (d:\test-api\node_modules\loopback-datasource-juggler\lib\connectors\memory.js:432:22)
    at Memory.all (d:\test-api\node_modules\loopback-datasource-juggler\lib\connectors\memory.js:506:20)
    at invokeConnectorMethod (d:\test-api\node_modules\loopback-datasource-juggler\lib\dao.js:169:21)
    at d:\test-api\node_modules\loopback-datasource-juggler\lib\dao.js:2131:7
    at doNotify (d:\test-api\node_modules\loopback-datasource-juggler\lib\observer.js:155:49)
    at d:\test-api\node_modules\loopback-datasource-juggler\lib\observer.js:168:23
    at d:\test-api\node_modules\async\dist\async.js:473:16
    at replenish (d:\test-api\node_modules\async\dist\async.js:1006:25)
    at d:\test-api\node_modules\async\dist\async.js:1016:9
    at eachLimit (d:\test-api\node_modules\async\dist\async.js:3196:24)
    at Object.<anonymous> (d:\test-api\node_modules\async\dist\async.js:1046:16)
    at doNotify (d:\test-api\node_modules\loopback-datasource-juggler\lib\observer.js:157:11)
    at doNotify (d:\test-api\node_modules\loopback-datasource-juggler\lib\observer.js:155:49)
    at doNotify (d:\test-api\node_modules\loopback-datasource-juggler\lib\observer.js:155:49)
    at doNotify (d:\test-api\node_modules\loopback-datasource-juggler\lib\observer.js:155:49)

如果我将登录 api url 更改为 /Users/login,它会 returns 预期的 401。任何想法出了什么问题?

显然清除数据库并首先创建用户解决了问题。如果尚未将任何实体输入数据库,则问题存在。