Grails - Spring Security - redirect to specific page when remember_me cookie is present

StackOverflow https://stackoverflow.com/questions/23466513

  •  15-07-2023
  •  | 
  •  

Pregunta

When the user is "looged in"(remember_me cookie) and access the website I want to open a specific page Eg: /welcome.

If the user is not "logged in" I want to open another page. Eg: /

Right now Im achieving this with javascript but Im sure there is a better solution. Through UrlMappings.groovy or config.grooy but didn't find any example.

This is what I'm doing right now:

//redirect to welcome page if user is connected
var cookie_rm = $.cookie('sc_remember_me');
if(cookie_rm && window.location.pathname == "/"){
    window.location.href = "/welcome"
}

Thank you

Lorenzo

¿Fue útil?

Solución

Yo can easily achieve this by using SecurityFilters.groovy. check the example given in grails documentation.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top