0

使用 feathers-authentication 可以使用可配置的用户名字段对用户进行身份验证。目前,我可以将身份验证配置为使用我的用户模型的usernameORemail字段,但我想为我们的用户提供两个选项usernameAND email

这样做的最佳方法是什么?

4

1 回答 1

5

显然,可以连接身份验证方法,因此解决方案应该类似于:

app.configure(auth({ secret: 'super secret' }))
  .configure(local()) // defaults usernameField to 'email'
  .configure(local({ // support username
    name: 'local-username',
    usernameField: 'username'
}));

更完整的示例可以在 GitHub 上找到:https ://github.com/jaredhanson/passport-local/pull/148#issuecomment-261506180

于 2016-11-24T01:20:27.397 回答