I am new to Grails and working on a project which has just 2 controllers one is for login and the other is for a explorer (similar to a windows explorer with left panel displaying a tree -like structure and the right displays the folders contents as a table)
The application is working as excpected meaning when user accesses the application it displays Login Screen if user hasn’t logged in and if he has logged in it displays the explorer screen.
But this is not the case on session Timeout: suppose the session has timed out and the user clicks on a link in the right panel of the explorer screen then the login screen is displayed within the right panel.
I am using SecurityFilter to redirect to login screen.
SecurityFilters.groovy
def filters = {
loginCheck(controller:'*', action:'*') {
before = {
if (!session.idpuser && actionName != "login") {
redirect(controller: "user", action: "login")
return false
}
}
}
}
userController.groovy
def login () {
if (request.get) {
return false
}
......
redirect(controller: "explorer", action: "file")
}
explorerController.groovy
def generateFiles = {
.....
render(template: 'list', model: [ dirList: dirList])
}
UrlMappings.groovy
static mappings = {
"/$controller/$action?/$id?"{
constraints {
// apply constraints here
}
}
"/"(action:"file", controller: "explorer")
"500"(view:'/error')
}
The reason I think login.gsp is being rendered in the right panel is because when a user click on a link in right panel “generateFiles” action is invoked and that is rendering login.gsp as a template within explorer.gsp. But I dont know how to fix it 🙁
I would appreciate if someone can help me with this issue.
PLEASE HELP!!!!!
Since this is an ajax based site, you need to explicitly handle the “you need to login” response in your ajax response handlers and force the user to the login page if needed.