Reputation: 52500
I'm using Spring 3.0 along with Spring Security. I've always used the following configuration:
<form-login login-page="/login" authentication-failure-url="/login?error=credentials" default-target-url="/account" login-processing-url="/security_check"/>
So when the user doesn't login correctly, they go to /login. Now I have a login dialog on every page of the site. If they don't login correctly, I don't want them redirecting to /login.. instead I want them returning to the page they are at. I'll them popup that same dialog when I see the error=credentials as a parameter.
So how do I do this?
Upvotes: 8
Views: 7746
Reputation: 33335
<!-- redirect url for failure of authentication -->
<bean id="simpleUrlAuthenticationFailureHandler" class="org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler">
<constructor-arg value="/login.jsp?error=1"></constructor-arg>
</bean>
I would suggest getting access to the object from the context and resetting the url OR writing your own custom handler which might perform actions specific to the page you are on
Upvotes: 2