我试图强制用户在首次登录时更改其密码(如此处Grails spring-security - Can I intercept before success action to check required password change?所述)。
但是,UsernamePasswordAuthenticationFilter.SPRING_SECURITY_LAST_USERNAME_KEY
(也已弃用)和springSecurityService.authentication.name
都不提供输入的用户名。我得到的只是__grails.anonymous.user__
,不能用于设置用户的新密码。
你们中有谁知道如何确定输入的用户名?
非常感谢你。
最佳答案
您可以使用session.getAttribute(SpringSecurityUtils.SPRING_SECURITY_LAST_USERNAME_KEY)
我也必须在config.groovy中启用此属性
grails.plugin.springsecurity.apf.storeLastUsername=true
关于authentication - Grails-在LoginController的authfail中拦截输入的用户名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24994486/