- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
看起来beforeInsert永远不会触发,并且密码以纯文本格式存储在DB中,我有一个User域类,如下所示:
class User {
String email
String name
String surname
String phone
String password
static constraints = {
email(blank:false, email:true, unique:true)
name(blank:false)
surname(blank:false)
phone(blank:false)
password(blank:false, password:true)
}
def beforeInsert = { encodePassword() }
def beforeUpdate() {
if (isDirty('password')) {
encodePassword()
}
}
protected void encodePassword() {
password = springSecurityService.encodePassword(password)
}
}
最佳答案
这很奇怪,我不知道为什么,但是这行得通,我将beforeInsert var更改为一个方法,并添加了瞬时springSecurityService
class User {
transient springSecurityService
String email
String name
String surname
String phone
String password
static constraints = {
email(blank:false, email:true, unique:true)
name(blank:false)
surname(blank:false)
phone(blank:false)
password(blank:false, password:true)
}
def beforeInsert() {
encodePassword()
}
def beforeUpdate() {
if (isDirty('password')) {
encodePassword()
}
}
protected void encodePassword() {
password = springSecurityService.encodePassword(password)
}
}
关于mongodb - grails + mongodb中未触发beforeInsert,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14492317/
我有一个 Grails 2.2.1 项目,其域名名为“Question”。在此域中,beforeinsert() 目前如下所示: def beforeInsert() { dateCreate
我有一个简单的hasMany关联-一个UserGroup hasMany Users,而该UserGroup由一个User拥有: class UserGroup { String name
给定这样的域星座: abstract class A { def myService def beforeInsert() { myService.doIt()
我想自动设置我的 DomainClasses 的 modifiedBy 和 createdBy 属性。 为此,我将 Bootstrap.grooy 更改为: import org.codehaus.g
在旧的 Grails 版本中,我们在域类中有这些 beforeUpdate、beforeInsert、beforeSave 事件。 我在 Grails 3.x 中找不到它们了 - 我现在如何轻松处理这
我在我的应用程序中使用 grails 版本 2.1.0,我在我的域类中有一个 before 插入,它对密码进行如下编码。 包 com.valuelabs.bets.security 类 SecUser
我们公司使用的大多数域对象都会有一些共同的属性。这些代表创建对象的用户、最后更新对象的用户以及他们用来执行此操作的程序。 为了DRY 的利益退出我的域类后,我想找到某种方法将相同的 beforeIns
我是一名优秀的程序员,十分优秀!