羽毛身份验证无效登录

时间:2019-04-15 06:12:39

标签: feathersjs

我尝试使用本地身份验证,但收到错误消息“无效登录”。

  1. 我从客户端发送“本地”身份验证。服务器上收到的数据
{ strategy: 'local',
      email: 'email@gmail.com',
      password: '123' },
    { query: {},
      provider: 'socketio',
      headers: {},
      session: {},
      cookies: {} }

在authentication.js中

module.exports = function (app) {
  const config = app.get('authentication');

  // Set up authentication with the secret
  app.configure(authentication(config));
  app.configure(jwt());
  app.configure(local());

  app.configure(oauth2(Object.assign({
    name: 'auth0',
    Strategy: Auth0Strategy
  }, config.auth0)));

  app.service('authentication').hooks({
    before: {
      create: [
        (data)=>{console.log('auth',data.arguments)},
        authentication.hooks.authenticate(config.strategies),
      ],
      remove: [
        authentication.hooks.authenticate('jwt')
      ]
    }
  });
};
  1. 服务器在数据库中查找记录并返回查询结果
{ id: 1,
         email: 'email@gmail.com',
         password:
          '$2a$13$t2XZsqu/0t5jKSdbRUyZTOVOoZJVtiha3sN/Z8N0O190Z0DUJj70O',
         auth0Id: null,
         isVerified: null,
         verifyToken: 'string',
         verifyExpires: null,
         resetToken: 'string',
         resetExpires: null,
         createdAt: 2019-04-14T22:04:52.000Z,
         updatedAt: 2019-04-14T22:04:52.000Z }
  1. 此后,它尝试比较密码的哈希值,但是接收到的密码的哈希值不等于查询结果中的密码。收到的密码与当前时间结合在结果哈希中。

如何在羽毛中使用本地身份验证?

UPD

default.json中的配置

"authentication": {
    "secret": "my secret key here",
    "strategies": [
      "jwt",
      "local"
    ],
    "path": "/authentication",
    "service": "users",
    "jwt": {
      "header": {
        "typ": "access"
      },
      "audience": "https://yourdomain.com",
      "subject": "anonymous",
      "issuer": "feathers",
      "algorithm": "HS256",
      "expiresIn": "1d"
    },
    "local": {
      "entity": "user",
      "usernameField": "email",
      "passwordField": "password"
    },
    "auth0": {
      "clientID": "your auth0 client id",
      "clientSecret": "your auth0 client secret",
      "successRedirect": "/",
      "domain": "mydomain.auth0.com",
      "scopes": [
        "profile"
      ]
    }
  }

0 个答案:

没有答案
相关问题