如何在GORM视图中隐藏password
列:
我的域名类:
class SecUser {
static scaffold = true
transient springSecurityService
String username
String password
boolean enabled = true
boolean accountExpired
boolean accountLocked
boolean passwordExpired
static transients = ['springSecurityService']
static constraints = {
username blank: false, unique: true
password (display:false, blank: false)
}
static mapping = {
password column: '`password`'
}
Set<SecRole> getAuthorities() {
SecUserSecRole.findAllBySecUser(this).collect { it.secRole } as Set
}
def beforeInsert() {
encodePassword()
}
def beforeUpdate() {
if (isDirty('password')) {
encodePassword()
}
}
protected void encodePassword() {
password = springSecurityService.encodePassword(password)
// password = password
}
}
答案 0 :(得分:2)
display: false
约束用于从默认的scaffolded视图中隐藏属性。 https://github.com/jeffbrown/scaffolddisplay项目证明了这一点。您的应用中必须有一些东西阻碍了它。可能您生成了包含该属性的视图。可能你正在使用提供视图的插件。