I am trying to implement a login system such that the user is redirected back to the original request url. For example, if a user tries to access url '/books/list' (which requires login to access) then the user should be redirect to login page and after login, the user should be redirected to '/books/list', the original requested url. How do I do this ? My login controller looks like :
def index = { if (springSecurityService.isLoggedIn()) { redirect action: 'dashboard' //redirect uri: SpringSecurityUtils.securityConfig.login.filterProcessesUrl } else { redirect action: auth, params: params } } def auth = { def config = SpringSecurityUtils.securityConfig if (springSecurityService.isLoggedIn()) { redirect uri: config.successHandler.defaultTargetUrl return } String view = 'auth' String postUrl = "${request.contextPath}${config.apf.filterProcessesUrl}" render view: view, model: [postUrl: postUrl, rememberMeParameter: config.rememberMe.parameter] }