2016-11-22 170 views
0

使用feathers-authentication可以使用可配置的用戶名字段對用戶進行身份驗證。目前,我可以配置身份驗證以使用我的用戶模型的usernameemail字段,但我想向用戶提供選項usernameemail使用用戶名或電子郵件進行身份驗證

這樣做的最好方法是什麼?

回答

2

顯然,這是可能的串聯身份驗證方法,因此解決方案應該是這樣的:

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

相關問題