简体   繁体   English

Flask-Security-用于生成身份验证令牌而不是电子邮件的用户名

[英]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. 我正在开发使用Flask的应用程序,并将Flask-security用于基于令牌的身份验证功能。 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" 我尝试在用户模型中将'email'更改为'username'属性,但在请求身份验证令牌时抛出错误-“未提供电子邮件”

Is there some config flag that I am missing? 我缺少一些配置标志吗?

FYI, I am using MongoEngineUserDataStore 仅供参考,我正在使用MongoEngineUserDataStore

Thanks 谢谢

Use SECURITY_USER_IDENTITY_ATTRIBUTES = ['username'] 使用SECURITY_USER_IDENTITY_ATTRIBUTES = ['username']

From the docs : 文档

Specifies which attributes of the user object can be used for login. 指定用户对象的哪些属性可用于登录。 Defaults to ['email']. 默认为['email']。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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