我想在用户首次登录时显示一个屏幕。是否有最佳做法可以检查用户之前是否已登录?我正在使用Spring Security Core插件。
答案 0 :(得分:0)
Spring Security没有内置任何功能。我正在做类似的事情,但它取决于用户是否已接受许可协议。这是可以做你想要的示例过滤器代码。这是未经测试的:
def filters = {
neverLoggedIn(controller: "login", invert: true) {
before = {
if (springSecurityService.isLoggedIn()) {
def authenticatedUser = getLoggedInUserCode()
if (!authenticatedUser.hasLoggedInBefore) {
redirect controller: "someFirstLoginController", action: "index"
return false
}
}
}
after = { Map model -> }
afterView = { Exception e -> }
}
}