Vra

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

Was dit nuttig?

Oplossing

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

Gelisensieer onder: CC-BY-SA met toeskrywing
Nie verbonde aan StackOverflow
scroll top