[英]Grails - Spring Security UI Email for Username
我正在使用Grails 3.2.4,並試圖將User類的email屬性用作注冊的用戶名。
到目前為止,我已經設法使Spring Security Core使用以下配置設置將電子郵件用作用戶名:
grails.plugin.springsecurity.userLookup.usernamePropertyName='email'
但是,注冊功能似乎沒有考慮到這一點,也不允許我僅使用電子郵件和密碼注冊新用戶。
我已經做了一些嘗試來重寫RegisterController的嘗試,但是我仍然遇到有關空用戶名的不同錯誤。
看來我一定缺少一些非常簡單的東西。 任何幫助/方向,我們將不勝感激。
看來在spring-security-ui-3.0.0.M2版本中 , username
屬性可能不可覆蓋。
String paramNameToPropertyName(String paramName, String controllerName) {
// Properties in the ACL classes and RegistrationCode aren't currently
// configurable, and the PersistentLogin class is generated but its
// properties also aren't configurable. Since this method is only by
// the controllers to be able to hard-code param names and lookup the
// actual domain class property name we can short-circuit the logic here.
// Additionally there's no need to support nested properties (e.g.
// 'aclClass.className' for AclObjectIdentity search) since those are
// not used in GSP for classes with configurable properties.
if (!paramName) {
return paramName
}
Class<?> clazz = domainClassesByControllerName[controllerName]
String name
if (clazz) {
String key = paramName
if (paramName.endsWith('.id')) {
key = paramName[0..-4]
}
name = classMappings[clazz][key]
}
name ?: paramName
}
PS我現在通過在用戶域類中執行以下操作來解決此問題:
static transients = ["migrating"]]
String username = null
public void setEmail(String email) {
this.email = email
this.username = email
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.