Loopback.js - 隐藏密码属性不起作用

时间:2015-08-03 16:16:07

标签: node.js get loopbackjs

我有一个模特" MyUser"继承自loopback" User"模型。现在,我不希望这个模型公开password属性,所以我去阅读文档:

http://docs.strongloop.com/display/public/LB/Model+definition+JSON+file#ModeldefinitionJSONfile-Excludepropertiesfrombasemodel

http://docs.strongloop.com/display/public/LB/Model+definition+JSON+file#ModeldefinitionJSONfile-Hiddenproperties

然而,由于某种原因,这似乎并不起作用。我在这里留下一些代码:

{
  "name": "MyUser",
  "plural": "myusers",
  "base": "User",
  "idInjection": true,
  "options": {
    "validateUpsert": true
  },
  "properties": {
    "password": null,
    "firstName": {
      "type": "string"
    },
    "lastName": {
      "type": "string"
    }
  },
  "validations": [],
  "relations": {
    "cars": {
      "type": "hasMany",
      "model": "Car"
    }
  },
  "acls": [
    {
      "accessType": "*",
      "principalType": "ROLE",
      "principalId": "$everyone",
      "permission": "ALLOW"
    }
  ],
  "methods": []
}

提前致谢。

1 个答案:

答案 0 :(得分:2)

在您的示例中,您似乎排除了密码属性,而不是仅隐藏密码属性。根据您引用的示例,隐藏属性看起来更像这样:

  "properties": {
    ...
    "password": {
      "type": "string",
      "required": true
    },
...
   "hidden": ["password"],
...