1

我正在将 Stormpath 与 Express 一起使用,并且我想访问数据库中存在的特定用户的自定义数据,而不是以该用户身份登录。这将用于管理员风格的 UI,其中具有特定权限的用户可以编辑其他用户的自定义数据。

如何访问特定用户的数据,就像使用访问当前用户的数据一样req.user.customData

4

1 回答 1

3

如果您使用的是 express 库,您可以这样说:

app.get('stormpathApplication').getAccount(account_href_here, function(err, account) {
  if (err) throw err;
  account.getCustomData(function(err, data) {
    if (err) throw err;
    console.log(data);
  });
});

app.get('stormpathApplication')是一个应用程序对象,因此任何这些 API 文档都可以使用它:http ://docs.stormpath.com/nodejs/api/application

我是这个库的开发者,希望对你有帮助!

于 2015-02-07T09:59:56.990 回答