如何在hybris中进行不区分大小写的用户名验证?
答案 0 :(得分:3)
首先,您必须覆盖DefaultCustomerFacade的注册方法(commercefacades中的文件)。
你会发现默认的实施强制小写使你无法在你的uid中使用大写字符 - >
customer.setUid(registerData.getLogin().toLowerCase())
然后你必须创建一个带有别名“acceleratorAuthenticationProvider”的新bean,它覆盖方法的身份验证。
在这种方法中,你必须实现像
这样的东西final UserModel userModel = findUserCaseInsensitive(authentication.getName());
if (userModel != null)
{
usernameResult = userModel.getUid();
token = new UsernamePasswordAuthenticationToken(authentication.getName(), authentication.getCredentials());
token.setDetails(authentication.getDetails());
}
方法findUserCaseInsensitive
应调用将执行灵活搜索的DAO。
这是一个例子:
SELECT {user.PK} FROM {User as user} WHERE lower({user.uid}) = lower(?uid)