From 09e547cc4926a4d3f188ca35cff7eb53fa4c2a64 Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Thu, 25 Apr 2024 01:22:32 -0700 Subject: [PATCH 01/18] Added 'Recovery email is not added.' case --- src/main.html | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main.html b/src/main.html index 0b865e3..3c38ed0 100644 --- a/src/main.html +++ b/src/main.html @@ -10,7 +10,8 @@ v-model="recoveryEmail" :placeholder="placeholder" /> - + + Date: Thu, 25 Apr 2024 01:34:22 -0700 Subject: [PATCH 02/18] Added 'Recovery email is not added.' case --- .../BeforeTemplateRenderedListener.php | 5 ++++- src/email-recovery.js | 17 ++++++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/lib/Listeners/BeforeTemplateRenderedListener.php b/lib/Listeners/BeforeTemplateRenderedListener.php index 63fb7e9..21a400e 100644 --- a/lib/Listeners/BeforeTemplateRenderedListener.php +++ b/lib/Listeners/BeforeTemplateRenderedListener.php @@ -33,8 +33,11 @@ class BeforeTemplateRenderedListener implements IEventListener { if (($event->getResponse()->getRenderAs() === TemplateResponse::RENDER_AS_USER) && $event->isLoggedIn() && !empty($this->userId)) { $recoveryEmail = $this->recoveryEmailService->getRecoveryEmail($this->userId); if ($recoveryEmail === '') { + $unverifiedRecoveryEmail = $this->recoveryEmailService->getUnverifiedRecoveryEmail($this->userId); $this->util->addStyle($this->appName, 'email-recovery'); - $this->util->addScript($this->appName, $this->appName . '-email-recovery'); + $this->util->addScript($this->appName, $this->appName . '-email-recovery', [ + 'unverifiedRecoveryEmail' => $unverifiedRecoveryEmail + ]); } } } diff --git a/src/email-recovery.js b/src/email-recovery.js index d715cc2..c81c175 100644 --- a/src/email-recovery.js +++ b/src/email-recovery.js @@ -5,7 +5,11 @@ document.addEventListener('DOMContentLoaded', function() { const contentDiv = document.createElement('div') contentDiv.id = 'recovery-email-banner-container' const img = createImageElement(APPLICATION_NAME) - const textNode = createTextNode(APPLICATION_NAME) + if(unverifiedRecoveryEmail != ''){ + var textNode = createTextNodeForUnverifiedEmail(APPLICATION_NAME) + }else{ + var textNode = createTextNode(APPLICATION_NAME) + } const link = createLinkElement(APPLICATION_NAME) contentDiv.appendChild(img) @@ -132,6 +136,17 @@ function createTextNode(appName) { return p } +/** + * + * @param appName + */ +function createTextNodeForUnverifiedEmail(appName) { + const p = document.createElement('p') + const text = document.createTextNode(t(appName, 'Recovery email is not verified.')) + p.appendChild(text) + return p +} + /** * * @param appName -- GitLab From bec1f6b6291f939f81fb8f1f1dd2d65ec2fa0b72 Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Thu, 25 Apr 2024 18:04:33 -0700 Subject: [PATCH 03/18] added eslint --- src/email-recovery.js | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/src/email-recovery.js b/src/email-recovery.js index c81c175..0df5149 100644 --- a/src/email-recovery.js +++ b/src/email-recovery.js @@ -5,11 +5,7 @@ document.addEventListener('DOMContentLoaded', function() { const contentDiv = document.createElement('div') contentDiv.id = 'recovery-email-banner-container' const img = createImageElement(APPLICATION_NAME) - if(unverifiedRecoveryEmail != ''){ - var textNode = createTextNodeForUnverifiedEmail(APPLICATION_NAME) - }else{ - var textNode = createTextNode(APPLICATION_NAME) - } + const textNode = createTextNode(APPLICATION_NAME) const link = createLinkElement(APPLICATION_NAME) contentDiv.appendChild(img) @@ -40,6 +36,11 @@ document.addEventListener('DOMContentLoaded', function() { * @param {string} topValue - The value to be set for the 'top' property. */ +/** + * + * @param selector + * @param topValue + */ function setTopStyleWhenElementAvailable(selector, topValue) { // Function to check each node and apply style if it matches the selector /** @@ -131,18 +132,13 @@ function createImageElement(appName) { */ function createTextNode(appName) { const p = document.createElement('p') - const text = document.createTextNode(t(appName, 'Please set your recovery email address to use your email account without restrictions.')) - p.appendChild(text) - return p -} - -/** - * - * @param appName - */ -function createTextNodeForUnverifiedEmail(appName) { - const p = document.createElement('p') - const text = document.createTextNode(t(appName, 'Recovery email is not verified.')) + let label = t(appName, 'Please set your recovery email address to use your email account without restrictions.') + /* eslint-disable */ + if (unverifiedRecoveryEmail !== '') { + label = t(appName, 'Please add recovery email address.') + } + /* eslint-enable */ + const text = document.createTextNode(label) p.appendChild(text) return p } -- GitLab From aa70519584e53ea580c611ce05403c54fa9f4786 Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Thu, 25 Apr 2024 18:10:33 -0700 Subject: [PATCH 04/18] removed double && --- src/main.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.html b/src/main.html index 3c38ed0..843416f 100644 --- a/src/main.html +++ b/src/main.html @@ -23,7 +23,7 @@ -

+

{{ t("email-recovery","Please check your inbox. An email has been sent to you for verification.") }}

-

+

{{ t( "email-recovery", errorKey ) }}

-- GitLab From 77c571d1b169f10d92d3b5e1843b2a135fa9a7b1 Mon Sep 17 00:00:00 2001 From: Aude M Date: Fri, 10 May 2024 05:30:48 +0000 Subject: [PATCH 18/18] applying Aude's suggestions. --- l10n/fr.js | 2 +- l10n/fr.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/l10n/fr.js b/l10n/fr.js index 392a93a..9cc8d78 100644 --- a/l10n/fr.js +++ b/l10n/fr.js @@ -30,6 +30,6 @@ OC.L10N.register( "You verified recovery email successfully.": "Vous avez vérifié l'email de récupération avec succès.", "Could not verify recovery email because the token is expired": "Impossible de vérifier l'e-mail de récupération car le jeton a expiré.", "Could not verify recovery email because the token is invalid": "Impossible de vérifier l'e-mail de récupération car le jeton n'est pas valide.", - "Unverified recovery email:": "Courriel de récupération non vérifié :" + "Unverified recovery email:": "E-mail de récupération non vérifié :" }, "nplurals=2; plural=n > 1;"); diff --git a/l10n/fr.json b/l10n/fr.json index 136eb11..ca59632 100644 --- a/l10n/fr.json +++ b/l10n/fr.json @@ -28,7 +28,7 @@ "You verified recovery email successfully.": "Vous avez vérifié l'email de récupération avec succès.", "Could not verify recovery email because the token is expired": "Impossible de vérifier l'e-mail de récupération car le jeton a expiré.", "Could not verify recovery email because the token is invalid": "Impossible de vérifier l'e-mail de récupération car le jeton n'est pas valide.", - "Unverified recovery email:": "Courriel de récupération non vérifié :" + "Unverified recovery email:": "E-mail de récupération non vérifié :" },"pluralForm" :"nplurals=2; plural=n > 1;" } \ No newline at end of file -- GitLab