使用用户名或电子邮件进行身份验证
Authentication using username or email
使用 feathers-authentication 可以使用可配置的用户名字段对用户进行身份验证。目前,我可以将身份验证配置为使用我的用户模型的 username
或 email
字段,但我想为我们的用户提供 username
和 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
使用 feathers-authentication 可以使用可配置的用户名字段对用户进行身份验证。目前,我可以将身份验证配置为使用我的用户模型的 username
或 email
字段,但我想为我们的用户提供 username
和 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