Express和jsonwebtoken,防止配置对象的return
Express and jsonwebtoken, prevent return of config object
我使用 express、bookshelf、mysql、bcrypt 和 jsonwebtoken 成功完成了注册过程。在我的前端,我有 angular console.log'ing returned 响应。我得到一个看起来像这样的对象:
{ config: ..., data: ..., headers: ... status: 200 ....}
数据对象有我的令牌,一切看起来都很棒。问题是配置对象。它具有明文形式的用户名、密码和密码验证。这似乎是个坏主意。我宁愿 return 令牌本身。我不知道它是来自 express 还是其他插件。有问题的文件位于 https://github.com/vrodriguez363/ng-express-gulp/blob/master/src/server/routes/api.js This question is similar to ,但没有得到答复。我记录的对象看起来像他的屏幕截图。
看起来 Angular 正在这样做(参见 here):
The response object has these properties:
- data –
{string|Object}
– The response body transformed with the transform functions.
- status –
{number}
– HTTP status code of the response.
- headers –
{function([headerName])}
– Header getter function.
- config –
{Object}
– The configuration object that was used to generate the request.
- statusText –
{string}
– HTTP status text of the response. (here)
因此,您看到的正在记录的用户凭据是存在于您传递给 $http{,.post,.get)()
的对象中的凭据。
FWIW,在浏览器的开发工具中,您可以查看 Express 发回的实际响应(通常在 Network 选项卡中)。
我使用 express、bookshelf、mysql、bcrypt 和 jsonwebtoken 成功完成了注册过程。在我的前端,我有 angular console.log'ing returned 响应。我得到一个看起来像这样的对象:
{ config: ..., data: ..., headers: ... status: 200 ....}
数据对象有我的令牌,一切看起来都很棒。问题是配置对象。它具有明文形式的用户名、密码和密码验证。这似乎是个坏主意。我宁愿 return 令牌本身。我不知道它是来自 express 还是其他插件。有问题的文件位于 https://github.com/vrodriguez363/ng-express-gulp/blob/master/src/server/routes/api.js This question is similar to ,但没有得到答复。我记录的对象看起来像他的屏幕截图。
看起来 Angular 正在这样做(参见 here):
The response object has these properties:
- data –
{string|Object}
– The response body transformed with the transform functions.- status –
{number}
– HTTP status code of the response.- headers –
{function([headerName])}
– Header getter function.- config –
{Object}
– The configuration object that was used to generate the request.- statusText –
{string}
– HTTP status text of the response. (here)
因此,您看到的正在记录的用户凭据是存在于您传递给 $http{,.post,.get)()
的对象中的凭据。
FWIW,在浏览器的开发工具中,您可以查看 Express 发回的实际响应(通常在 Network 选项卡中)。