From 78a613b1dea4b753a108b3c3402e3669d7da6f5d Mon Sep 17 00:00:00 2001 From: rrajoria Date: Mon, 26 Sep 2022 12:29:13 +0530 Subject: [PATCH 1/3] ACA-4619: Forgot Password Changes --- .../ResetPasswordServiceImpl.java | 45 ++++++++++++++----- .../main/java/org/alfresco/util/UrlUtil.java | 34 ++++++++++++++ .../config/repo-clients-apps.properties | 7 +++ .../forgot-password-email-template.ftl | 12 +++++ 4 files changed, 86 insertions(+), 12 deletions(-) create mode 100644 repository/src/main/resources/alfresco/templates/reset-password-email-templates/forgot-password-email-template.ftl diff --git a/repository/src/main/java/org/alfresco/repo/security/authentication/ResetPasswordServiceImpl.java b/repository/src/main/java/org/alfresco/repo/security/authentication/ResetPasswordServiceImpl.java index 530002af89..a7ace09702 100644 --- a/repository/src/main/java/org/alfresco/repo/security/authentication/ResetPasswordServiceImpl.java +++ b/repository/src/main/java/org/alfresco/repo/security/authentication/ResetPasswordServiceImpl.java @@ -504,6 +504,21 @@ public class ResetPasswordServiceImpl implements ResetPasswordService return UrlUtil.replaceShareUrlPlaceholder(url, sysAdminParams); } + private String getAdwUrl(String url, String propName) + { + if (url == null) + { + LOGGER.warn("The url for the property [" + propName + "] is not configured."); + return ""; + } + + if (url.endsWith("/")) + { + url = url.substring(0, url.length() - 1); + } + return UrlUtil.replaceAdwUrlPlaceholder(url, sysAdminParams); + } + protected String getResetPasswordEmailTemplate(ClientApp clientApp) { return clientApp.getProperty("requestResetPasswordTemplatePath"); @@ -522,22 +537,28 @@ public class ResetPasswordServiceImpl implements ResetPasswordService StringBuilder sb = new StringBuilder(100); String pageUrl = clientApp.getProperty("resetPasswordPageUrl"); - if (StringUtils.isEmpty(pageUrl)) - { - sb.append(UrlUtil.getShareUrl(sysAdminParams)); - LOGGER.warn("'resetPasswordPageUrl' property is not set for the client [" + clientApp.getName() + if(clientApp.getName().equals("adw")) { + sb.append(getAdwUrl(pageUrl, "")); + LOGGER.warn("Client Name is " + clientApp.getName() + " The url used is " + sb.toString()); + sb.append("?key=").append(key) + .append("&id=").append(BPMEngineRegistry.createGlobalId(ActivitiConstants.ENGINE_ID, id)).append("&userName=").append(userName); + + } + else { + if (StringUtils.isEmpty(pageUrl)) { + sb.append(UrlUtil.getShareUrl(sysAdminParams)); + + LOGGER.warn("'resetPasswordPageUrl' property is not set for the client [" + clientApp.getName() + "]. The default base url of Share will be used [" + sb.toString() + "]"); - } - else - { - // We pass an empty string as we know that the pageUrl is not null - sb.append(getUrl(pageUrl, "")); - } + } else { + // We pass an empty string as we know that the pageUrl is not null + sb.append(getUrl(pageUrl, "")); + } - sb.append("?key=").append(key) + sb.append("?key=").append(key) .append("&id=").append(BPMEngineRegistry.createGlobalId(ActivitiConstants.ENGINE_ID, id)); - + } return sb.toString(); } diff --git a/repository/src/main/java/org/alfresco/util/UrlUtil.java b/repository/src/main/java/org/alfresco/util/UrlUtil.java index f040c31858..c8d57b7596 100644 --- a/repository/src/main/java/org/alfresco/util/UrlUtil.java +++ b/repository/src/main/java/org/alfresco/util/UrlUtil.java @@ -146,4 +146,38 @@ public class UrlUtil url.append(context); return url.toString(); } + + /** + * Builds up the Url to Adw based on the settings in the + * {@link SysAdminParams}. + * @return Adw Url such as https://col.ab.or.ate/#/ + * or http://localhost:8081/#/ + */ + public static String getAdwUrl(SysAdminParams sysAdminParams) + { + return buildUrl( + sysAdminParams.getAlfrescoProtocol(), + sysAdminParams.getAlfrescoHost(), + sysAdminParams.getAlfrescoPort(), + "#"); + } + + /** + * Replaces the adw url placeholder, namely {@literal ${alfrescoUrl}}, with adw url. + * + * @param value the string value which contains the share url placeholder + * @param sysAdminParams the {@code SysAdminParams} object + * @return if the given {@code value} contains share url placeholder, + * the placeholder is replaced with share url; otherwise, the given {@code value} is simply returned + */ + + public static String replaceAdwUrlPlaceholder(String value, SysAdminParams sysAdminParams) + { + if (value != null) + { + return REPO_PATTERN.matcher(value).replaceAll(getAdwUrl(sysAdminParams)); + } + return value; + } + } diff --git a/repository/src/main/resources/alfresco/client/config/repo-clients-apps.properties b/repository/src/main/resources/alfresco/client/config/repo-clients-apps.properties index 16e27a74e1..b47f062167 100644 --- a/repository/src/main/resources/alfresco/client/config/repo-clients-apps.properties +++ b/repository/src/main/resources/alfresco/client/config/repo-clients-apps.properties @@ -23,3 +23,10 @@ repo.client-app.share.confirmResetPasswordTemplatePath= repo.client-app.workspace.inviteModeratedTemplatePath= repo.client-app.workspace.workspaceUrl=workspace repo.client-app.workspace.templateAssetsUrl=${alfrescoUrl}/images + +# reset password request email template path +repo.client-app.adw.requestResetPasswordTemplatePath=alfresco/templates/reset-password-email-templates/forgot-password-email-template.ftl +# reset password UI page url +repo.client-app.adw.resetPasswordPageUrl=${alfrescoUrl}/reset-password/ +# reset password confirmation email template path +repo.client-app.adw.confirmResetPasswordTemplatePath= \ No newline at end of file diff --git a/repository/src/main/resources/alfresco/templates/reset-password-email-templates/forgot-password-email-template.ftl b/repository/src/main/resources/alfresco/templates/reset-password-email-templates/forgot-password-email-template.ftl new file mode 100644 index 0000000000..170532a6ac --- /dev/null +++ b/repository/src/main/resources/alfresco/templates/reset-password-email-templates/forgot-password-email-template.ftl @@ -0,0 +1,12 @@ + + + Forgot Password + + +

You are receiving this email because you(or someone else) requested the password reset of your account.

+

Please click on the following link, or paste this url into your browser to complete the process:

+

${reset_password_url}

+

If you received this in error, you can safely ignore it.

+

Kind regards

+ + \ No newline at end of file From e5ea6db30c36815e26a36ace5fb6cb5463f055c0 Mon Sep 17 00:00:00 2001 From: rrajoria Date: Mon, 26 Sep 2022 12:45:40 +0530 Subject: [PATCH 2/3] ACA-4619: Forgot Password Changes --- .../security/authentication/ResetPasswordServiceImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/repository/src/main/java/org/alfresco/repo/security/authentication/ResetPasswordServiceImpl.java b/repository/src/main/java/org/alfresco/repo/security/authentication/ResetPasswordServiceImpl.java index a7ace09702..834fe1bee3 100644 --- a/repository/src/main/java/org/alfresco/repo/security/authentication/ResetPasswordServiceImpl.java +++ b/repository/src/main/java/org/alfresco/repo/security/authentication/ResetPasswordServiceImpl.java @@ -373,7 +373,7 @@ public class ResetPasswordServiceImpl implements ResetPasswordService final ClientApp clientApp = getClientAppConfig(clientName); Map emailTemplateModel = Collections.singletonMap(FTL_RESET_PASSWORD_URL, - createResetPasswordUrl(clientApp, id, key)); + createResetPasswordUrl(clientApp, id, key, userName)); final String templatePath = emailHelper.getEmailTemplate(clientName, getResetPasswordEmailTemplate(clientApp), @@ -532,7 +532,7 @@ public class ResetPasswordServiceImpl implements ResetPasswordService /** * This method creates a URL for the 'reset password' link which appears in the email */ - protected String createResetPasswordUrl(ClientApp clientApp, final String id, final String key) + protected String createResetPasswordUrl(ClientApp clientApp, final String id, final String key, final String userName) { StringBuilder sb = new StringBuilder(100); From 1e7dc6ed8da5df639c940d13fc81740d00d5212c Mon Sep 17 00:00:00 2001 From: MohinishSah <88024811+MohinishSah@users.noreply.github.com> Date: Mon, 14 Nov 2022 10:54:40 +0530 Subject: [PATCH 3/3] update Gdrive version --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 0dd67c991f..96c30648b5 100644 --- a/pom.xml +++ b/pom.xml @@ -109,7 +109,7 @@ 2.7.0 1.1.4 - 3.3.1-A1 + 3.3.1-A2 1.5.0 7.3.0