I am attempting to generate an error message for users that are currently not validated. These users should get an message, which is shown at /login?error
. It already goes to this url when the user authentication goes wrong, but this is obviously done in the authentication success handler. This is the success handler:
@Override
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws ServletException, IOException {
super.onAuthenticationSuccess(request, response, authentication);
}
}
How would I go about still returning to an error page when the authentication is successful, but the user is set on inactive? I assume it should be done in this function. All help is welcome!
EDIT: The idea is to check users for their active
status. Each user has a field 'active' in the database, which will be set true by an admin. How spring is currently configured, is that the onAuthenticationSuccess
handler will be called, since the credentials are good. I actually want to reject the user from logging in when the user has active = false