1

当我提取在 Mac 中运行良好的项目的工作代码时,在 Windows 中进行身份验证时出现此错误

错误

{
"name": "NotAuthenticated",
"message": "Invalid login",
"code": 401,
"className": "not-authenticated",
"errors": {}

}

发布请求

{

    "strategy": "local",
      "username": "demo",
      "password": "demo"

}

默认.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"
    }

},

所以本地策略根本不起作用

4

1 回答 1

5

来自文档羽毛文档

“重要提示:如果您想在 Windows 下的配置文件中将 usernameField 的值设置为 username,该值必须转义为\\username(否则将使用用户名环境变量)”

因此 default.json 中需要的代码更改是

  "local": {
  "usernameField": "\\username",
  "passwordField": "password"
   }
于 2020-04-27T19:23:21.860 回答