Вопрос

I all,

After an authentication I want to redirect the user to the address specified in the url. For that I implement this code:

In the loginController:

def auth = {        
   def savedRequest = session.getAttribute(WebAttributes.SAVED_REQUEST)  

...}

and in config.groovy:

grails.plugins.springsecurity.useSecurityEventListener = true

grails.plugins.springsecurity.onAuthenticationSuccessEvent = { e, appCtx ->

def savedRequest = session.getAttribute(WebAttributes.SAVED_REQUEST);
String requestUrl = savedRequest.getRedirectUrl()
}

grails.plugins.springsecurity.successHandler.defaultTargetUrl = requestUrl 

After submitting the login I have this error:

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.codehaus.groovy.runtime.InvokerInvocationException: groovy.lang.MissingMethodException: No signature of method: groovy.util.ConfigObject.getAttribute() is applicable for argument types: (groovy.util.ConfigObject) values: [[:]] java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) java.lang.Thread.run(Thread.java:619) root cause

groovy.lang.MissingMethodException: No signature of method: groovy.util.ConfigObject.getAttribute() is applicable for argument types: (groovy.util.ConfigObject) values: [[:]] script1379418399441191405188$_run_closure3.doCall(script1379418399441191405188.groovy:154) java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) java.lang.Thread.run(Thread.java:619) note The full stack trace of the root cause is available in the Apache Tomcat/7.0.25 logs.

Это было полезно?

Решение

Spring security should do this automatically unless you have it turned off.

This will take the user to a url if they didnt specify one or if the setting is off after a successful login

grails.plugins.springsecurity.successHandler.defaultTargetUrl = ""

This setting you can simply not specify or set to false. This states that every time the user logs in they will be redirected to the default target url regardless of what page they attempted to access before they got the authorization request. So, if I understand you correct, set this to false or dont specify it at all and the functionality you want should work.

grails.plugins.springsecurity.successHandler.alwaysUseDefault=true
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top