Passing or setting up the auth note in authentication session

Hey All -

Here’s the use case, I am trying to get advice on -

With default authentication flow (browser flow) enabled, with user registration enabled for realm, can we or is there a way to set auth note in authentication session with value from the username field on the user id password form, so it is available and pre-populated on the registration or forgot password forms, when user clicks on Registration or Forgot Password link.

context.getAuthenticationSession().setAuthNote(ATTEMPTED_USERNAME, {whatever values from the username field on the form});

Thanks,
Shashank