Aja*_*rge 1 windows node.js feathers-authentication
当我提取在 Mac 中运行良好的项目的工作代码时,在 Windows 中进行身份验证时出现此错误
错误
{
"name": "NotAuthenticated",
"message": "Invalid login",
"code": 401,
"className": "not-authenticated",
"errors": {}
Run Code Online (Sandbox Code Playgroud)
}
发布请求
{
"strategy": "local",
"username": "demo",
"password": "demo"
}
Run Code Online (Sandbox Code Playgroud)
默认.json
"authentication": {
"entity": "user",
"service": "users",
"secret": "2wVrC38R9sUb6Cjhuhoir3oate0=",
"authStrategies": [
"jwt",
"local"
],
"jwtOptions": {
"header": {
"type": "access"
},
"audience": "https://yourdomain.com",
"issuer": "feathers",
"algorithm": "HS256",
"expiresIn": "1d"
},
"local": {
"usernameField": "username",
"passwordField": "password"
}
Run Code Online (Sandbox Code Playgroud)
},
所以本地策略根本不起作用
来自文档羽毛 doc
“重要提示:如果您想在 Windows 下将配置文件中 usernameField 的值设置为 username,则该值必须转义为\\username(否则将使用 username 环境变量)”
因此 default.json 中需要的代码更改是
"local": {
"usernameField": "\\username",
"passwordField": "password"
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
549 次 |
| 最近记录: |