在Spring security ui plugin / Registercontroller中 我注册了一些登录凭证......邮件被发送到电子邮件.... 注册令牌和用户名存储在注册_code表中... 但是用户不是在sec_user表中创建的。
我的代码
def register = { RegisterCommand command ->
println("am before command")
if (command.hasErrors()) {
render view: 'index', model: [command: command]
return
}
String salt = saltSource instanceof NullSaltSource ? null :command.username
//String password =
springSecurityService.encodePassword(command.password,salt)
String password=command.password
println("lookup userclas--------------"+lookupUserClass())
def user = lookupUserClass().newInstance(email: command.email, username:
command.username,password: password, accountLocked: true, enabled: true)
println("user objct is------------------"+user)
if (!user.validate() || !user.save()) {
// TODO
println("user saved-------------"+user.save())
}
def registrationCode = new RegistrationCode(username: user.username).save()
String url = generateLink('verifyRegistration', [t:
registrationCode.token])
println("url is-----------"+url)
def conf = SpringSecurityUtils.securityConfig
def body = conf.ui.register.emailBody
println("body is--------------"+body)
if (body.contains('$')) {
body = evaluate(body, [user: user, url: url])
}
mailService.sendMail {
to command.email
from conf.ui.register.emailFrom
subject conf.ui.register.emailSubject
html body.toString()
}
render view: 'index', model: [emailSent: true]
}
未创建用户对象..... lookupUserclass(0值是Sec_User我得到
答案 0 :(得分:1)
如果你正在看
用户已保存-------------
表示保存失败。这可能就是你的问题所在。出于某种原因,您没有创建有效的用户。例如,基本sec_user中没有电子邮件字段。