Skip to content

Commit

Permalink
IT-515 refactor login with keycloak and password show KC-23
Browse files Browse the repository at this point in the history
  • Loading branch information
DMinnai committed Feb 21, 2024
1 parent 5f7d4eb commit 075f82a
Show file tree
Hide file tree
Showing 4 changed files with 658 additions and 498 deletions.
153 changes: 74 additions & 79 deletions themes/entando/login/login-update-password.ftl
Original file line number Diff line number Diff line change
@@ -1,80 +1,75 @@
<#import "template.ftl" as layout>
<#import "password-commons.ftl" as passwordCommons>
<@layout.registrationLayout displayMessage=!messagesPerField.existsError('password','password-confirm'); section>
<#if section = "header">
${msg("updatePasswordTitle")}
<#elseif section = "form">
<form id="kc-passwd-update-form" class="${properties.kcFormClass!}" action="${url.loginAction}" method="post">
<div class="${properties.kcFormGroupClass!}">
<div class="${properties.kcLabelWrapperClass!}">
<label for="password-new" class="${properties.kcLabelClass!}">${msg("passwordNew")}</label>
</div>
<div class="${properties.kcInputWrapperClass!}">
<div class="${properties.kcInputGroup!}">
<input type="password" id="password-new" name="password-new" class="${properties.kcInputClass!}"
autofocus autocomplete="new-password"
aria-invalid="<#if messagesPerField.existsError('password','password-confirm')>true</#if>"
/>

<button class="${properties.kcFormPasswordVisibilityButtonClass!}" type="button" aria-label="${msg('showPassword')}"
aria-controls="password-new" data-password-toggle
data-icon-show="${properties.kcFormPasswordVisibilityIconShow!}" data-icon-hide="${properties.kcFormPasswordVisibilityIconHide!}"
data-label-show="${msg('showPassword')}" data-label-hide="${msg('hidePassword')}">
<i class="${properties.kcFormPasswordVisibilityIconShow!}" aria-hidden="true"></i>
</button>

</div>

<#if messagesPerField.existsError('password')>
<span id="input-error-password" class="${properties.kcInputErrorMessageClass!}" aria-live="polite">
${kcSanitize(messagesPerField.get('password'))?no_esc}
</span>
</#if>
</div>
</div>

<div class="${properties.kcFormGroupClass!}">
<div class="${properties.kcLabelWrapperClass!}">
<label for="password-confirm" class="${properties.kcLabelClass!}">${msg("passwordConfirm")}</label>
</div>
<div class="${properties.kcInputWrapperClass!}">
<div class="${properties.kcInputGroup!}">
<input type="password" id="password-confirm" name="password-confirm"
class="${properties.kcInputClass!}"
autocomplete="new-password"
aria-invalid="<#if messagesPerField.existsError('password-confirm')>true</#if>"
/>

<button class="${properties.kcFormPasswordVisibilityButtonClass!}" type="button" aria-label="${msg('showPassword')}"
aria-controls="password-confirm" data-password-toggle
data-icon-show="${properties.kcFormPasswordVisibilityIconShow!}" data-icon-hide="${properties.kcFormPasswordVisibilityIconHide!}"
data-label-show="${msg('showPassword')}" data-label-hide="${msg('hidePassword')}">
<i class="${properties.kcFormPasswordVisibilityIconShow!}" aria-hidden="true"></i>
</button>

</div>

<#if messagesPerField.existsError('password-confirm')>
<span id="input-error-password-confirm" class="${properties.kcInputErrorMessageClass!}" aria-live="polite">
${kcSanitize(messagesPerField.get('password-confirm'))?no_esc}
</span>
</#if>

</div>
</div>

<div class="${properties.kcFormGroupClass!}">
<#-- <@passwordCommons.logoutOtherSessions/> -->
<div id="kc-form-buttons" class="${properties.kcFormButtonsClass!}">
<#if isAppInitiatedAction??>
<input class="${properties.kcButtonClass!} ${properties.kcButtonPrimaryClass!} ${properties.kcButtonLargeClass!}" type="submit" value="${msg("doSubmit")}" />
<button class="${properties.kcButtonClass!} ${properties.kcButtonDefaultClass!} ${properties.kcButtonLargeClass!}" type="submit" name="cancel-aia" value="true" />${msg("doCancel")}</button>
<#else>
<input class="${properties.kcButtonClass!} ${properties.kcButtonPrimaryClass!} ${properties.kcButtonBlockClass!} ${properties.kcButtonLargeClass!}" type="submit" value="${msg("doSubmit")}" />
</#if>
</div>
</div>
</form>
<script type="module" src="${url.resourcesPath}/js/passwordVisibility.js"></script>
</#if>
</@layout.registrationLayout>
<#import "password-commons.ftl" as passwordCommons>
<@layout.registrationLayout displayMessage=!messagesPerField.existsError('password','password-confirm'); section>
<#if section="header">
${msg("updatePasswordTitle")}
<#elseif section="form">
<form id="kc-passwd-update-form" class="${properties.kcFormClass!}" action="${url.loginAction}" method="post">
<div class="${properties.kcFormGroupClass!}">
<div class="${properties.kcLabelWrapperClass!}">
<label for="password-new" class="${properties.kcLabelClass!}">
${msg("passwordNew")}
</label>
</div>
<div class="${properties.kcInputWrapperClass!}">
<div class="${properties.kcInputGroup!}">
<input type="password" id="password-new" name="password-new" class="${properties.kcInputClass!}"
autofocus autocomplete="new-password"
aria-invalid="<#if messagesPerField.existsError('password','password-confirm')>true</#if>" />
<button class="${properties.kcFormPasswordVisibilityButtonClass!}" type="button" aria-label="${msg('showPassword')}"
aria-controls="password-new" data-password-toggle
data-icon-show="${properties.kcFormPasswordVisibilityIconShow!}" data-icon-hide="${properties.kcFormPasswordVisibilityIconHide!}"
data-label-show="${msg('showPassword')}" data-label-hide="${msg('hidePassword')}">
<i class="${properties.kcFormPasswordVisibilityIconShow!}" aria-hidden="true"></i>
</button>
</div>
<#if messagesPerField.existsError('password')>
<span id="input-error-password" class="${properties.kcInputErrorMessageClass!}" aria-live="polite">
${kcSanitize(messagesPerField.get('password'))?no_esc}
</span>
</#if>
</div>
</div>
<div class="${properties.kcFormGroupClass!}">
<div class="${properties.kcLabelWrapperClass!}">
<label for="password-confirm" class="${properties.kcLabelClass!}">
${msg("passwordConfirm")}
</label>
</div>
<div class="${properties.kcInputWrapperClass!}">
<div class="${properties.kcInputGroup!}">
<input type="password" id="password-confirm" name="password-confirm"
class="${properties.kcInputClass!}"
autocomplete="new-password"
aria-invalid="<#if messagesPerField.existsError('password-confirm')>true</#if>" />
<button class="${properties.kcFormPasswordVisibilityButtonClass!}" type="button" aria-label="${msg('showPassword')}"
aria-controls="password-confirm" data-password-toggle
data-icon-show="${properties.kcFormPasswordVisibilityIconShow!}" data-icon-hide="${properties.kcFormPasswordVisibilityIconHide!}"
data-label-show="${msg('showPassword')}" data-label-hide="${msg('hidePassword')}">
<i class="${properties.kcFormPasswordVisibilityIconShow!}" aria-hidden="true"></i>
</button>
</div>
<#if messagesPerField.existsError('password-confirm')>
<span id="input-error-password-confirm" class="${properties.kcInputErrorMessageClass!}" aria-live="polite">
${kcSanitize(messagesPerField.get('password-confirm'))?no_esc}
</span>
</#if>
</div>
</div>
<div class="${properties.kcFormGroupClass!}">
<#-- <@passwordCommons.logoutOtherSessions /> -->
<div id="kc-form-buttons" class="${properties.kcFormButtonsClass!}">
<#if isAppInitiatedAction??>
<input class="${properties.kcButtonClass!} ${properties.kcButtonPrimaryClass!} ${properties.kcButtonLargeClass!}" type="submit" value="${msg("doSubmit")}" />
<button class="${properties.kcButtonClass!} ${properties.kcButtonDefaultClass!} ${properties.kcButtonLargeClass!}" type="submit" name="cancel-aia" value="true" />
${msg("doCancel")}
</button>
<#else>
<input class="${properties.kcButtonClass!} ${properties.kcButtonPrimaryClass!} ${properties.kcButtonBlockClass!} ${properties.kcButtonLargeClass!}" type="submit" value="${msg("doSubmit")}" />
</#if>
</div>
</div>
</form>
<script type="module" src="${url.resourcesPath}/js/passwordVisibility.js"></script>
</#if>
</@layout.registrationLayout>
124 changes: 77 additions & 47 deletions themes/entando/login/login.ftl
Original file line number Diff line number Diff line change
@@ -1,55 +1,85 @@
<#import "template.ftl" as layout>
<@layout.registrationLayout displayInfo=social.displayInfo; section>
<#if section = "title">
${msg("loginTitle",(realm.displayName!''))}
<#elseif section = "form">
<form class="LoginPage__form" action="${url.loginAction}" method="post">
<div class="LoginPage__formGroup">
<div class="LoginPage__inputGroup">
<label class="LoginPage__label">${msg("username")}</label>
<input type="text" name="username" tabindex="1" class="LoginPage__input" id="username" placeholder="Username" />
</div>
<div class="LoginPage__inputGroup extra-margin">
<label class="LoginPage__label">${msg("password")}</label>
<input type="password" name="password" tabindex="2" class="LoginPage__input" id="password" placeholder="Password" />
</div>
<#if message?has_content>
<div class="LoginPage__error">${message.summary?no_esc}</div>
<div class="LoginPage__actionGroup" style="margin-top: 0;">
<div></div>
<button class="LoginPage__button" type="submit">${msg("doLogIn")}</button>
<div class="LoginPage__loading">
<div class="LoginPage__spinner" />
<@layout.registrationLayout displayMessage=!messagesPerField.existsError('username','password') displayInfo=social.displayInfo && realm.password && !registrationDisabled??; section>
<#if section="title">
${msg("loginTitle",(realm.displayName!''))}
<#elseif section="form">
<form class="LoginPage__form" action="${url.loginAction}" method="post">
<div class="LoginPage__formGroup">
<#if !usernameHidden??>
<div class="LoginPage__inputGroup extra-margin">
<label class="LoginPage__label">
${msg("username")}
</label>
<div class="${properties.kcInputGroup!}">
<input type="text" name="username" tabindex="1" class="LoginPage__input" id="username" placeholder="Username" />
</div>
</div>
</div>
<#else>
<div class="LoginPage__actionGroup">
<div></div>
<button class="LoginPage__button" type="submit">${msg("doLogIn")}</button>
<div class="LoginPage__loading">
<div class="LoginPage__spinner" />
</#if>
<div class="LoginPage__inputGroup extra-margin">
<label class="LoginPage__label">
${msg("password")}
</label>
<div class="${properties.kcInputGroup!}">
<input type="password" name="password" tabindex="2" class="LoginPage__input" id="password" autocomplete="password" placeholder="Password" />
<button class="${properties.kcFormPasswordVisibilityButtonClass!}" type="button" aria-label="${msg('showPassword')}"
aria-controls="password" data-password-toggle
data-icon-show="${properties.kcFormPasswordVisibilityIconShow!}" data-icon-hide="${properties.kcFormPasswordVisibilityIconHide!}"
data-label-show="${msg('showPassword')}" data-label-hide="${msg('hidePassword')}">
<i class="${properties.kcFormPasswordVisibilityIconShow!}" aria-hidden="true"></i>
</button>
</div>
<#if usernameHidden?? && messagesPerField.existsError('username','password')>
<span id="input-error" class="${properties.kcInputErrorMessageClass!}" aria-live="polite">
${kcSanitize(messagesPerField.getFirstError('username','password'))?no_esc}
</span>
</#if>
</div>
</#if>
</div>
<#if social.providers??>
<div class="LoginPage__social">
${msg("socialLogin")}
<#if message?has_content>
<div class="LoginPage__error">
${message.summary?no_esc}
</div>
<div class="LoginPage__actionGroup" style="margin-top: 0;">
<div></div>
<button class="LoginPage__button" type="submit">
${msg("doLogIn")}
</button>
<div class="LoginPage__loading">
<div class="LoginPage__spinner" />
</div>
</div>
<#else>
<div class="LoginPage__actionGroup">
<div></div>
<button class="LoginPage__button" type="submit">
${msg("doLogIn")}
</button>
<div class="LoginPage__loading">
<div class="LoginPage__spinner" />
</div>
</div>
</#if>
</div>
</#if>
<div>
<#if social.providers??>
<div id="social-providers">
<div id="kc-social-providers">
<ul class="list horizontal">
<#list social.providers as p>
<li><a href="${p.loginUrl}" id="zocial-${p.alias}" class="button zocial ${p.providerId}">${p.displayName}</a></li>
</#list>
</ul>
</div>
<div class="LoginPage__social">
${msg("socialLogin")}
</div>
</#if>
</div>
</form>
</#if>
</@layout.registrationLayout>
<div>
<#if social.providers??>
<div id="social-providers">
<div id="kc-social-providers">
<ul class="list horizontal">
<#list social.providers as p>
<li><a href="${p.loginUrl}" id="zocial-${p.alias}" class="button zocial ${p.providerId}">
${p.displayName}
</a></li>
</#list>
</ul>
</div>
</div>
</#if>
</div>
</form>
<script type="module" src="${url.resourcesPath}/js/passwordVisibility.js"></script>
</#if>
</@layout.registrationLayout>
Loading

0 comments on commit 075f82a

Please sign in to comment.