如何在Feathers js中设置JWT身份验证?

时间:2020-04-19 04:31:35

标签: javascript feathersjs feathers-authentication

我总结的步骤总结如下。 我已经使用npm安装了Feathers js cli,并使用本地策略通过身份验证创建了feathers应用程序。 当我致电/ authentication时,响应说无效登录

我如何使用用户表中的用户服务评估用户并发送回带有选定字段的jwt令牌。

const { LocalStrategy } = require("@feathersjs/authentication-local");
const { expressOauth } = require("@feathersjs/authentication-oauth");
class MyLocalStrategy extends LocalStrategy {
  async getEntityQuery(query, params) {
    // Query for user but only include users marked as `active`
    return {
      ...query,
      //active: true,
      $limit: 1,
    };
  }
}

module.exports = (app) => {
  const authentication = new AuthenticationService(app);
  const config = app.get("authentication");
  authentication.register("jwt", new JWTStrategy());
  // authentication.register("local", new LocalStrategy());
  authentication.register("local", new MyLocalStrategy());
  app.use("/authentication", authentication);

  app.configure(expressOauth());
};

0 个答案:

没有答案
相关问题