How to route users after login based on role

I have two different user roles, let’s say USER and ADMIN. The main view of the application is annotated like this:

@Route(value = "admin")
@RouteAlias(value = "")

and the user’s view like this:

@Route(value = "user")
@RolesAllowed({"USER", "ADMIN"})

As you can see, I want to have the /admin view also be available under the root /. But when a user logs in the user gets redirected to / after login and then gets the RouteAccessDeniedError view.

I would like to have the user being redirected to /user after successful login. Any advice how to do this?

Thank you!

I have now implemented it like this. Could you give me an advice if this the correct approach?

public class RouteAccessDeniedRerouter extends RouteAccessDeniedError {

    private final AccessAnnotationChecker accessChecker;

    public RouteAccessDeniedRerouter(AccessAnnotationChecker accessChecker, AuthenticatedUser authenticatedUser) {
        this.accessChecker = accessChecker;

    public int setErrorParameter(BeforeEnterEvent event, ErrorParameter<AccessDeniedException> parameter) {
        if (accessChecker.hasAccess(UserView.class)) {
            return HttpStatusCode.TEMPORARY_REDIRECT.getCode();

        return HttpStatusCode.UNAUTHORIZED.getCode();

This looks like a hack. Normally this should be done with AuthenticationSuccessHandler of Spring Security. Sadly integrating that into the default Vaadin Web Security might be a little bit tricky.