Skip to content

Commit

Permalink
Identity recovery tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
patrixstar committed Aug 31, 2023
1 parent e791310 commit 6ebc65f
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,12 @@ <h4 class="login-box-msg" wicket:id="panelTitle"></h4>
<a wicket:id="switchToDefaultSequence" class="text-center"/>
</div>
</wicket:enclosure>
</div>

<div class="d-flex flex-wrap gap-2 justify-content-between mb-2 login-panel-control">
<a class="text-center login-panel-control mt-2" style="display: inline-block;" wicket:id="back">
<i class="fas fa-arrow-left mr-2"></i>
<wicket:message key="PageEmailNonce.backButtonLabel"/>
</a>
<div class="d-flex flex-wrap gap-2 justify-content-between login-panel-control">
<a class="btn text-center text-primary login-panel-control mt-2" style="display: inline-block;" wicket:id="back">
<i class="fas fa-arrow-left mr-2"></i>
<wicket:message key="PageEmailNonce.backButtonLabel"/>
</a>
</div>
</div>
<div class="card-footer login-footer" wicket:id="footerContainer">
<span class="pull-right hidden-xs" wicket:id="version">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<form method="post" class="form-horizontal" wicket:id="form">
<div wicket:id="csrfField"/>
<input type="hidden" wicket:id="attributeValues"/>
<wicket:child/>
<wicket:child class="mt-4"/>
<div wicket:id="attributes" class="d-flex flex-column my-2 justify-content-between login-panel-control">
<!-- <div wicket:id="attributePanel"></div>-->
<label wicket:id="attributeName"></label>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,38 @@
<wicket:extend>

<wicket:child/>

<wicket:enclosure child="flowLinkContainer">
<div class="d-flex align-items-center my-2">
<hr class="w-100" style="border-color: #818d98;">
<span class="mx-3 text-secondary">OR</span>
<hr class="w-100" style="border-color: #818d98;">
</div>

<div wicket:id="flowLinkContainer">
<wicket:enclosure child="identityRecovery">
<div class="d-flex justify-content-end mt-2">
<a wicket:id="identityRecovery" class="text-center login-panel-control">
<a wicket:id="identityRecovery" class="btn btn-default text-center login-panel-control">
<div wicket:id="identityRecoveryLabel"/>
</a>
</div>
</wicket:enclosure>
<wicket:enclosure child="resetPassword">
<div class="d-flex justify-content-end mt-2">
<a wicket:id="resetPassword" class="text-center login-panel-control">
<a wicket:id="resetPassword" class="btn btn-default text-center login-panel-control">
<div wicket:id="resetPasswordLabel"/>
</a>
</div>
</wicket:enclosure>
<wicket:enclosure child="selfRegistration">
<div class="d-flex justify-content-end mt-2">
<a wicket:id="selfRegistration" class="text-center login-panel-control">
<a wicket:id="selfRegistration" class="btn btn-default text-center login-panel-control">
<div wicket:id="selfRegistrationLabel"/>
</a>
</div>
</wicket:enclosure>
</div>
</wicket:enclosure>

</wicket:extend>
</body>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public abstract class PageAbstractAuthenticationModule<MA extends ModuleAuthenti

private static final Trace LOGGER = TraceManager.getTrace(PageLogin.class);

private static final String ID_FLOW_LINK_CONTAINER = "flowLinkContainer";
private static final String ID_IDENTITY_RECOVERY = "identityRecovery";
private static final String ID_IDENTITY_RECOVERY_LABEL = "identityRecoveryLabel";
private static final String ID_RESET_PASSWORD = "resetPassword";
Expand Down Expand Up @@ -123,10 +124,14 @@ protected final void initCustomLayout() {
form.add(AttributeModifier.replace("action", (IModel<String>) this::getUrlProcessingLogin));
add(form);

WebMarkupContainer flowLinkContainer = new WebMarkupContainer(ID_FLOW_LINK_CONTAINER);

add(flowLinkContainer);

SecurityPolicyType securityPolicy = loadSecurityPolicyType();
addIdentityRecoveryLink(securityPolicy);
addForgotPasswordLink(securityPolicy);
addRegistrationLink(securityPolicy);
addIdentityRecoveryLink(flowLinkContainer, securityPolicy);
addForgotPasswordLink(flowLinkContainer, securityPolicy);
addRegistrationLink(flowLinkContainer, securityPolicy);

WebMarkupContainer csrfField = SecurityUtils.createHiddenInputForCsrf(ID_CSRF_FIELD);
form.add(csrfField);
Expand Down Expand Up @@ -168,17 +173,17 @@ protected void confirmAuthentication() {
}
}

private void addIdentityRecoveryLink(SecurityPolicyType securityPolicy) {
private void addIdentityRecoveryLink(WebMarkupContainer flowLinkContainer, SecurityPolicyType securityPolicy) {
String identityRecoveryUrl = SecurityUtils.getIdentityRecoveryUrl(securityPolicy);
var label = SecurityUtils.getIdentityRecoveryLabel(securityPolicy);
addExternalLink(ID_IDENTITY_RECOVERY, identityRecoveryUrl, ID_IDENTITY_RECOVERY_LABEL,
addExternalLink(flowLinkContainer, ID_IDENTITY_RECOVERY, identityRecoveryUrl, ID_IDENTITY_RECOVERY_LABEL,
StringUtils.isEmpty(label) ? "PageLogin.loginRecovery" : label);
}

private void addExternalLink(String componentId, String linkUrl, String labelComponentId, String labelKeyOrValue) {
private void addExternalLink(WebMarkupContainer flowLinkContainer, String componentId, String linkUrl, String labelComponentId, String labelKeyOrValue) {
ExternalLink link = new ExternalLink(componentId, linkUrl);
link.add(new VisibleBehaviour(() -> StringUtils.isNotBlank(linkUrl) && isLoginAndFirstModule()));
add(link);
flowLinkContainer.add(link);

Label linkLabel = new Label(labelComponentId, createStringResource(labelKeyOrValue));
link.add(linkLabel);
Expand All @@ -202,20 +207,21 @@ private boolean isLoginAndFirstModule() {

}

private void addForgotPasswordLink(SecurityPolicyType securityPolicy) {
private void addForgotPasswordLink(WebMarkupContainer flowLinkContainer, SecurityPolicyType securityPolicy) {
String urlResetPass = SecurityUtils.getPasswordResetUrl(securityPolicy);
var label = SecurityUtils.getPasswordResetLabel(securityPolicy);
addExternalLink(ID_RESET_PASSWORD, urlResetPass, ID_RESET_PASSWORD_LABEL,
addExternalLink(flowLinkContainer, ID_RESET_PASSWORD, urlResetPass, ID_RESET_PASSWORD_LABEL,
StringUtils.isEmpty(label) ? "PageLogin.resetPassword" : label);
}

private void addRegistrationLink(SecurityPolicyType securityPolicyType) {
private void addRegistrationLink(WebMarkupContainer flowLinkContainer, SecurityPolicyType securityPolicyType) {
String urlRegistration = SecurityUtils.getRegistrationUrl(securityPolicyType);
var label = SecurityUtils.getRegistrationLabel(securityPolicyType);
addExternalLink(ID_SELF_REGISTRATION, urlRegistration, ID_SELF_REGISTRATION_LABEL,
addExternalLink(flowLinkContainer, ID_SELF_REGISTRATION, urlRegistration, ID_SELF_REGISTRATION_LABEL,
StringUtils.isEmpty(label) ? "PageLogin.registerNewAccount" : label);
}


private SecurityPolicyType loadSecurityPolicyType() {
return securityPolicyModel.getObject();
}
Expand Down

0 comments on commit 6ebc65f

Please sign in to comment.