KEYCLOAK-17446 - Prefill username in "Forgot Your Password" form if

called from Login form
This commit is contained in:
Vlastimil Elias 2021-03-17 11:43:11 +01:00 committed by Pedro Igor
parent b87d764137
commit 82491ae5d2
2 changed files with 2 additions and 7 deletions

View file

@ -63,7 +63,7 @@ public class AuthenticationContextBean {
String username = context.getAuthenticationSession().getAuthNote(AbstractUsernameFormAuthenticator.ATTEMPTED_USERNAME);
// Fallback to real username of the user just if attemptedUsername doesn't exist
if (username == null) {
if (username == null && context.getUser() != null) {
username = context.getUser().getUsername();
}

View file

@ -9,12 +9,7 @@
<label for="username" class="${properties.kcLabelClass!}"><#if !realm.loginWithEmailAllowed>${msg("username")}<#elseif !realm.registrationEmailAsUsername>${msg("usernameOrEmail")}<#else>${msg("email")}</#if></label>
</div>
<div class="${properties.kcInputWrapperClass!}">
<#if auth?has_content && auth.showUsername()>
<input type="text" id="username" name="username" class="${properties.kcInputClass!}" autofocus value="${auth.attemptedUsername}" aria-invalid="<#if messagesPerField.existsError('username')>true</#if>"/>
<#else>
<input type="text" id="username" name="username" class="${properties.kcInputClass!}" autofocus aria-invalid="<#if messagesPerField.existsError('username')>true</#if>"/>
</#if>
<input type="text" id="username" name="username" class="${properties.kcInputClass!}" autofocus value="${(auth.attemptedUsername!'')}" aria-invalid="<#if messagesPerField.existsError('username')>true</#if>"/>
<#if messagesPerField.existsError('username')>
<span id="input-error-username" class="${properties.kcInputErrorMessageClass!}" aria-live="polite">
${kcSanitize(messagesPerField.get('username'))?no_esc}