我正在尝试用“email”替换用户名,用“motDePasse”替换密码但是我无法弄清楚如何做到这一点:我试图用Person类中的新名称替换每个旧名称而我将以下配置添加到
my application.groovy :
grails.plugin.springsecurity.userLookup.usernamePropertyName= 'email'
grails.plugin.springsecurity.userLookup.passwordPropertyName= 'motDePasse'
但它不起作用。我正在使用grails 3.1.5,有人可以帮我吗?
文档的“ Custom UserDetailsService ”部分未显示如何替换属性。
谢谢
答案 0 :(得分:0)
我最后保留了默认密码并用电子邮件替换了用户名,我只需更换每个"用户名"用"电子邮件"在Person类中:
<table>
<div id="row1">
<tr> <td> r1c1 </td> <td> r1c2</td> </tr>
</div>
<div id="row2">
<tr> <td> r2c1</td> <td> r2c2 </td> </tr>
</div>
<div id="row3">
<tr> <td> r3c1 </td> <td> r3c2</td> </tr>
</div>
<tr>
<td>-</td> <td> <button class="add_row"> Add Another Row </button> </td>
</tr>
</table>
并添加
package ma.ac.uir.ecine.authentification
import groovy.transform.EqualsAndHashCode
import groovy.transform.ToString
@EqualsAndHashCode(includes='email')
@ToString(includes='email', includeNames=true, includePackage=false)
class Personne implements Serializable {
private static final long serialVersionUID = 1
transient springSecurityService
String email
String password
boolean enabled = true
boolean accountExpired
boolean accountLocked
boolean passwordExpired
Personne(String email, String password) {
this()
this.email = email
this.password = password
}
Set<Role> getAuthorities() {
PersonneRole.findAllByPersonne(this)*.role
}
def beforeInsert() {
encodePassword()
}
def beforeUpdate() {
if (isDirty('password')) {
encodePassword()
}
}
protected void encodePassword() {
password = springSecurityService?.passwordEncoder ? springSecurityService.encodePassword(password) : password
}
static transients = ['springSecurityService']
static constraints = {
password blank: false, password: true
email blank: false, unique: true
}
static mapping = {
password column: '`password`'
}
}
到application.groovy
我无法替换密码。