Grails Interceptors - To Many Redirects
15/04/2018 23:35
?class AuthInterceptor {
AuthInterceptor() {
match(controller: '*', action: '*').excludes(controller: 'auth')
}
boolean before() {
if (notLogged()) {
redirect controller: 'auth', action: 'index'
return false
}
if (pendingChangePassword()) {
redirect controller: 'user', action: 'password'
return false
}
true
}
boolean after() { true }
void afterView() {}
private boolean notLogged() {
if (session?.user) {
return false
}
return true
}
private boolean pendingChangePassword() {
if (session?.user?.status == Credentials.Status.CHANGE_PASSWORD) {
return true
}
return false
}
}
Para se registrar, clique aqui.