简体   繁体   English

grails spring安全核心插件-使用用户名和电子邮件登录

[英]grails spring security core plugin - login with username and email

Can the spring security call be configured to be able to authentication by email and username? 可以将spring安全呼叫配置为能够通过电子邮件和用户名进行身份验证吗? Currently as I can see from the doc that userLookup.userDomainClassName is configured to match one field, saying username for example so user needs to input the username to login. 目前,正如我从文档中看到的那样,将userLookup.userDomainClassName配置为匹配一个字段,例如说用户名,因此用户需要输入用户名才能登录。 Is is possible to enable user to login with email or username? 是否可以使用户使用电子邮件或用户名登录?

You can accomplish this by creating a Custom UserDetailsSerice . 您可以通过创建Custom UserDetailsS​​erice来实现。

In the implementation of loadUserByUsername search first by username, then if that fails, search by email. loadUserByUsername的实现中,首先按用户名搜索,然后如果失败,则通过电子邮件搜索。

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

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