Reputation: 1040
I have the spring security redirecting to the login page whenever the user is not authenticated with
<form-login login-page="/login/"
authentication-failure-handler-ref="customAuthenticationFailureHandler"
authentication-success-handler-ref="customAuthenticationSuccessHandler"
username-parameter="j_username"
password-parameter="j_password"
login-processing-url="/j_spring_security_check"
always-use-default-target="false" />
But now I have an AJAX call that can return this login page. Is it possible instead of return the login page, when the call is made using ajax, to return the 401?
Thanks
Upvotes: 1
Views: 523
Reputation: 1040
I already found the solution. Doing this https://gist.github.com/bmchild/5569833 I have the 401 if the request is ajax and redirect to login otherwise
Upvotes: 1