cancelLogin() on Keycloak authentication flow

Hello All,

We have a condition where the user clicks the cancel button on the login page and we want the authentication flow to be cancelled and the user redirected back to the login page.

// When the user clicks cancel this is what we are doing.
 // If the user wants to cancel the login flow
    if (getFormParameter(context.getHttpRequest().getDecodedFormParameters(), "kc-otp-button-cancel") != null) {
        logger.warn("Cancelling login per user's request");
        context.cancelLogin();
        return;
    }

Post this, what happens is, the user is not taken to the login screen and the same screen refreshes and does nothing, I also see that the same screen is refreshed and hence assuming that the session is kept alive.

Any help appreciated.

Did you try to reset the flow / subflow?