使用 feathers-authentication 可以使用可配置的用户名字段对用户进行身份验证。目前,我可以将身份验证配置为使用我的用户模型的username
ORemail
字段,但我想为我们的用户提供两个选项username
AND email
。
这样做的最佳方法是什么?
使用 feathers-authentication 可以使用可配置的用户名字段对用户进行身份验证。目前,我可以将身份验证配置为使用我的用户模型的username
ORemail
字段,但我想为我们的用户提供两个选项username
AND email
。
这样做的最佳方法是什么?
显然,可以连接身份验证方法,因此解决方案应该类似于:
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