How can I change the failure or message on login page?

after enabled force detection and lock some accounts Temporarily,i want to continue using those accounts to login,and the login page will show me “invalid username / password”. Now I want the login page show me something like “account is locked, try it later”. How can I develop it ,with spi or changing ftl ?

You’ll have to customize the Authenticator that does the username/password test, and then customize the message key that gets sent to the error.ftl page. You’ll probably have to create the file in a separate theme in order to do that. Here are the docs for both. Post follow up questions here if you have them.

1 Like

thanks ,i just did it.
But i delete some code in method authenticate

public void authenticate(AuthenticationFlowContext context) {
        MultivaluedMap<String, String> formData = new MultivaluedMapImpl<>();
        String loginHint = context.getAuthenticationSession().getClientNote(OIDCLoginProtocol.LOGIN_HINT_PARAM);
//        String rememberMeUsername = AuthenticationManager.getRememberMeUsername(context.getRealm(), context.getHttpRequest().getHttpHeaders());
//        if (loginHint != null || rememberMeUsername != null) {
//            if (loginHint != null) {
//                formData.add(AuthenticationManager.FORM_USERNAME, loginHint);
//            } else {
//                formData.add(AuthenticationManager.FORM_USERNAME, rememberMeUsername);
//                formData.add("rememberMe", "on");
//            }
//        }
        Response challengeResponse = challenge(context, formData);

seems that i delete the remeber me options. Because if not deleting these code ,it will case exception noclass ‘AuthenticationManager’ exist . How can I solve this problem ? thank you