This is a follow up to this question.
I have a custom AuthenticationProvider that extends AbstractUserDetailsAuthenticationProvider. In the additionalAuthenticationChecks I am doing some custom auth work and part of this process is to display some messages to the user on the login screen. Currently, for testing, I created a UserNotActivatedException:
class UserNotActivatedException extends AuthenticationException {
public UserNotActivatedException(String message, Throwable t) {
super(message, t)
}
public UserNotActivatedException(String message) {
super(message)
}
public UserNotActivatedException(String message, Object extraInformation) {
super(message, extraInformation)
}
}
And in the additionalAuthenticationChecks I am just immediately throwing it for testing. Now, I need to know what I need to do to get my own fail message to show up on the login screen. In the spring-security-core default config, we can override the following:
errors.login.disabled = "Sorry, your account is disabled."
errors.login.expired = "Sorry, your account has expired."
errors.login.passwordExpired = "Sorry, your password has expired."
errors.login.locked = "Sorry, your account is locked."
errors.login.fail = "Sorry, we were not able to find a user with that username and password."
But I don’t see how I can add my own additional messages.
It looks like those messages just get used by the
authfailaction of theLoginControllerthat gets generated intograils-app/controllers. Here’s the code from the template (in the plugin):(from ~/.grails/1.3.7/projects/project-name/plugins/spring-security-core-1.1.2/src/templates/LoginController.groovy.template)
You can probably just add your UserNotActivatedException type to the conditions there.