When I have spring security settings as below:
<http pattern="/ui/**" auto-config="true" authentication-manager-ref="authenticationManager">
<intercept-url pattern="/ui/login*" access="isAnonymous() or hasRole('USER')" requires-channel="${web.channel}" />
<intercept-url pattern="/ui/**" access="hasRole('USER')" requires-channel="${web.channel}" />
<form-login login-page="/ui/login" login-processing-url="/ui/j_spring_security_check" default-target-url="/ui/dashboard" />
<logout logout-url="/ui/logout" logout-success-url="/ui/login" />
</http>
my controller is ignored and both methods are never invoked. I've tried adding breakpoints inside both of them but the execution never stops. I have also tried adding System.out.println() to them and nothing was written to system output, so I am pretty sure both methods are either not mapped or just never invoked.
@Controller
public class MyController {
@RequestMapping(value = { "/ui", "/ui/login"}, method = GET)
public String indexNoTrailingSlash() {
return index();
}
@RequestMapping(value = "/", method = GET)
public String index() {
return "redirect:/ui/dashboard";
}
}
Security works fine and thanks to default-target-url="/ui/dashboard" in the xml I do get to my dashboard page after successful login. What I want to achieve is, however, that a user is redirected to dashboard also if he's already logged in. I've tried to follow this answer and that's what I need the controller for. Is there a way either to map these methods so I can use my controller for redirecting or to somehow redirect with just spring security?
Thanks :)