Grails 3 Spring Security UI忘记密码空白URL&用户

时间:2016-08-11 18:54:27

标签: grails spring-security grails-3.1

我已自定义grails.plugin.springsecurity.userLookup.usernamePropertyName = "email",但电子邮件正文的默认呈现行为将失败:

No such property: username for class

因此,我在emailBody

中自定义了application.groovy

grails.plugin.springsecurity.ui.forgotPassword.emailBody = "Dear ${user.email} , Please follow <a href='${url}'>this link</a> to reset your password. This link will expire shortly."

因为根据文档:

  

emailBody属性应该是一个GString,并且在用户变量的范围内具有User域类实例,并且生成的url用于单击以重置url变量中的密码。

但是,对于MailStrategyuser.email值,包含我的url中的属性的参数地图为空:

[to:blah@blah.com, 
 from:no-reply@blah.com, subject:Reset your password for your account,
 html:Dear [:], Please follow <a href='[:']>this link</a> to reset your password. This link will expire shortly.]

请注意[:][:]的{​​{1}}和user.email

spring-security插件在url

中配置了这些值
application.groovy

grails.plugin.springsecurity.userLookup.userDomainClassName = 'blah.Account' grails.plugin.springsecurity.userLookup.authorityJoinClassName = 'blah.AccountRole' grails.plugin.springsecurity.authority.className = 'blah.Role' grails.plugin.springsecurity.requestMap.className = 'blah.Requestmap' grails.plugin.springsecurity.securityConfigType = 'Annotation' 类定义为:

Account

我如何拥有用户名,更重要的是我为我呈现的网址,以便发送忘记密码的电子邮件?

1 个答案:

答案 0 :(得分:0)

GString应该从&#34; 开始,而不是从&#39;

开始

所以而不是grails.plugin.springsecurity.ui.forgotPassword.emailBody = '...'

你应该使用:grails.plugin.springsecurity.ui.forgotPassword.emailBody = "..."