First, I created a new required action (RequiredActionProvider), let's call it ReLogin. It simply does a challenge:
@Override
public void requiredActionChallenge(RequiredActionContext context) {
// Look for a custom reLoginMessage in message.properties
Response response = context.form()
.setInfo("reLoginMessage")
.createForm("info.ftl");
context.challenge(response);
}
@Override
public void processAction(RequiredActionContext context) {
// Always fail
// The only way to remove this required action is to go through Login auth flow
context.failure();
}
Then, in the Event Listener (EventListenerProvider) I look for the UPDATE_PASSWORD event and put in an addRequiredAction:
user.addRequiredAction("ReLogin")
Finally, I added a new authentication flow execution (Authenticator) to login flows that does a removeRequiredAction:
user.removeRequiredAction("ReLogin");
It's very hacky and I wonder if there're other simpler ideas out there.
Benjamin