minor cleanup
This commit is contained in:
parent
6a6c546c0c
commit
4c5d2fe273
|
@ -10,6 +10,7 @@ import javax.servlet.http.HttpServletResponse;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.MessageSource;
|
||||
import org.springframework.security.core.AuthenticationException;
|
||||
import org.springframework.security.web.WebAttributes;
|
||||
import org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.servlet.LocaleResolver;
|
||||
|
@ -31,14 +32,16 @@ public class CustomAuthenticationFailureHandler extends SimpleUrlAuthenticationF
|
|||
|
||||
final Locale locale = localeResolver.resolveLocale(request);
|
||||
|
||||
String errorMessage = messages.getMessage("message.badCredentials", null, locale);
|
||||
|
||||
if (exception.getMessage().equalsIgnoreCase("User is disabled")) {
|
||||
request.getSession().setAttribute("SPRING_SECURITY_LAST_EXCEPTION", messages.getMessage("auth.message.disabled", null, locale));
|
||||
errorMessage = messages.getMessage("auth.message.disabled", null, locale);
|
||||
} else if (exception.getMessage().equalsIgnoreCase("User account has expired")) {
|
||||
request.getSession().setAttribute("SPRING_SECURITY_LAST_EXCEPTION", messages.getMessage("auth.message.expired", null, locale));
|
||||
errorMessage = messages.getMessage("auth.message.expired", null, locale);
|
||||
} else if (exception.getMessage().equalsIgnoreCase("blocked")) {
|
||||
request.getSession().setAttribute("SPRING_SECURITY_LAST_EXCEPTION", messages.getMessage("auth.message.blocked", null, locale));
|
||||
} else {
|
||||
request.getSession().setAttribute("SPRING_SECURITY_LAST_EXCEPTION", messages.getMessage("message.badCredentials", null, locale));
|
||||
}
|
||||
errorMessage = messages.getMessage("auth.message.blocked", null, locale);
|
||||
}
|
||||
|
||||
request.getSession().setAttribute(WebAttributes.AUTHENTICATION_EXCEPTION, errorMessage);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue