简体   繁体   中英

Flask-Security - Username to generate auth token instead of email

I am developing an application using Flask and using Flask-security for token based authentication feature. I developed a prototype code looking at docs and different examples I could find on internet. I see 'email' field is required to get a auth token. But I need 'username' field instead. I tried changing 'email' to 'username' attribute in the user model but it throws an error while requesting for the auth token - "Email not provided"

Is there some config flag that I am missing?

FYI, I am using MongoEngineUserDataStore

Thanks

Use SECURITY_USER_IDENTITY_ATTRIBUTES = ['username']

From the docs :

Specifies which attributes of the user object can be used for login. Defaults to ['email'].

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM