diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b4cb162bdb9a545c5a0876022038b1702dd7e0e9..2a6bee70c2728b03b1206cb25aaeab26a5321c1f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,5 +1,5 @@ variables: - TO_PACKAGE: 'appinfo css l10n lib templates js' + TO_PACKAGE: 'appinfo css l10n lib templates img js' include: - project: 'e/infra/ecloud/nextcloud-apps/ci-templates' diff --git a/img/warning.svg b/img/warning.svg new file mode 100644 index 0000000000000000000000000000000000000000..704197c70da341ac90ed4b5b0f2221cafaab95a1 --- /dev/null +++ b/img/warning.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/l10n/de.js b/l10n/de.js index c23bf04f9e1b3e4c0df0bd33f8bc2b22c8c2a4eb..d3ef459f88110cc102c2fb13d6b725d73ca2e230 100644 --- a/l10n/de.js +++ b/l10n/de.js @@ -24,6 +24,8 @@ OC.L10N.register( "You verified recovery email successfully.": "Sie haben die Wiederherstellungs-E-Mail erfolgreich verifiziert.", "Could not verify recovery email because the token is expired": "Wiederherstellungs-E-Mail konnte nicht verifiziert werden, da das Token abgelaufen ist", "Could not verify recovery email because the token is invalid": "Wiederherstellungs-E-Mail konnte nicht verifiziert werden, da das Token ungültig ist", - "Unverified recovery email:": "Nicht verifizierte Wiederherstellungs-E-Mail:" + "Unverified recovery email:": "Nicht verifizierte Wiederherstellungs-E-Mail:", + "Please set your recovery email address to use your email account without restrictions.": "Bitte geben Sie Ihre Wiederherstellungs-E-Mail-Adresse an, damit Sie Ihr E-Mail ohne Beschränkungen nutzen können.", + "SET RECOVERY EMAIL NOW": "MEINE WIEDERHERSTELLUNGS-E-MAIL-ADRESSE ANGEBEN" }, "nplurals=2; plural=n != 1;"); diff --git a/l10n/de.json b/l10n/de.json index b05534e374b74fd93dab393be91396244aa76b1b..72dcd1c72d7ccbea05487f0d71e03b443b4c4f65 100644 --- a/l10n/de.json +++ b/l10n/de.json @@ -22,6 +22,8 @@ "You verified recovery email successfully.": "Sie haben die Wiederherstellungs-E-Mail erfolgreich verifiziert.", "Could not verify recovery email because the token is expired": "Wiederherstellungs-E-Mail konnte nicht verifiziert werden, da das Token abgelaufen ist", "Could not verify recovery email because the token is invalid": "Wiederherstellungs-E-Mail konnte nicht verifiziert werden, da das Token ungültig ist", - "Unverified recovery email:": "Nicht verifizierte Wiederherstellungs-E-Mail:" + "Unverified recovery email:": "Nicht verifizierte Wiederherstellungs-E-Mail:", + "Please set your recovery email address to use your email account without restrictions.": "Bitte geben Sie Ihre Wiederherstellungs-E-Mail-Adresse an, damit Sie Ihr E-Mail ohne Beschränkungen nutzen können.", + "SET RECOVERY EMAIL NOW": "MEINE WIEDERHERSTELLUNGS-E-MAIL-ADRESSE ANGEBEN" },"pluralForm" :"nplurals=2; plural=n != 1;" } \ No newline at end of file diff --git a/l10n/en.js b/l10n/en.js index c7438644822be0d6f42802dc8afc3403d90dd924..55e2c6724d323bfd348c13d1a81f459ed41829bb 100644 --- a/l10n/en.js +++ b/l10n/en.js @@ -22,6 +22,8 @@ OC.L10N.register( "You verified recovery email successfully.": "You verified recovery email successfully.", "Could not verify recovery email because the token is expired": "Could not verify recovery email because the token is expired", "Could not verify recovery email because the token is invalid": "Could not verify recovery email because the token is invalid", - "Unverified recovery email:": "Unverified recovery email:" + "Unverified recovery email:": "Unverified recovery email:", + "Please set your recovery email address to use your email account without restrictions.": "Please set your recovery email address to use your email account without restrictions.", + "SET RECOVERY EMAIL NOW": "SET RECOVERY EMAIL NOW" }, "nplurals=2; plural=(n != 1);"); diff --git a/l10n/en.json b/l10n/en.json index 1193fd86f475224988c4652c678932d2fe69b4ca..5fad55ae50253898ba99d9cbb02788024357106b 100644 --- a/l10n/en.json +++ b/l10n/en.json @@ -21,7 +21,9 @@ "You verified recovery email successfully.": "You verified recovery email successfully.", "Could not verify recovery email because the token is expired": "Could not verify recovery email because the token is expired", "Could not verify recovery email because the token is invalid": "Could not verify recovery email because the token is invalid", - "Unverified recovery email:": "Unverified recovery email:" + "Unverified recovery email:": "Unverified recovery email:", + "Please set your recovery email address to use your email account without restrictions.": "Please set your recovery email address to use your email account without restrictions.", + "SET RECOVERY EMAIL NOW": "SET RECOVERY EMAIL NOW" }, "pluralForm": "nplurals=2; plural=(n != 1);" } \ No newline at end of file diff --git a/l10n/es.js b/l10n/es.js index 9169737a8530bc65ac01c771d8c8a0ddb5de97bc..f860c8622f15936d2a2861b405f6e7322d727391 100644 --- a/l10n/es.js +++ b/l10n/es.js @@ -24,6 +24,8 @@ OC.L10N.register( "You verified recovery email successfully.": "Ha verificado correctamente el correo electrónico de recuperación.", "Could not verify recovery email because the token is expired": "No se ha podido verificar el correo electrónico de recuperación porque el token ha caducado.", "Could not verify recovery email because the token is invalid": "No se ha podido verificar el correo electrónico de recuperación porque el token no es válido", - "Unverified recovery email:": "Correo electrónico de recuperación no verificado:" + "Unverified recovery email:": "Correo electrónico de recuperación no verificado:", + "Please set your recovery email address to use your email account without restrictions.": "Configura tu dirección de correo electrónico de recuperación para utilizar tu cuenta de correo electrónico sin restricciones.", + "SET RECOVERY EMAIL NOW": "CONFIGURAR CORREO ELECTRÓNICO DE RECUPERACIÓN" }, "nplurals=2; plural=n != 1;"); diff --git a/l10n/es.json b/l10n/es.json index 8d3aafbe2b34f2da5cf485bd7bf5f54368b66860..2b64cbb08a1cc74b9c8a5457268ba30a4725116f 100644 --- a/l10n/es.json +++ b/l10n/es.json @@ -22,6 +22,8 @@ "You verified recovery email successfully.": "Ha verificado correctamente el correo electrónico de recuperación.", "Could not verify recovery email because the token is expired": "No se ha podido verificar el correo electrónico de recuperación porque el token ha caducado.", "Could not verify recovery email because the token is invalid": "No se ha podido verificar el correo electrónico de recuperación porque el token no es válido", - "Unverified recovery email:": "Correo electrónico de recuperación no verificado:" + "Unverified recovery email:": "Correo electrónico de recuperación no verificado:", + "Please set your recovery email address to use your email account without restrictions.": "Configura tu dirección de correo electrónico de recuperación para utilizar tu cuenta de correo electrónico sin restricciones.", + "SET RECOVERY EMAIL NOW": "CONFIGURAR CORREO ELECTRÓNICO DE RECUPERACIÓN" },"pluralForm" :"nplurals=2; plural=n != 1;" } \ No newline at end of file diff --git a/l10n/fr.js b/l10n/fr.js index d86d48de2eb271566cd63ea231db0e8617805416..5fecfc12125beaad697f5410c7344cecdbb5667e 100644 --- a/l10n/fr.js +++ b/l10n/fr.js @@ -24,6 +24,8 @@ 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:": "Courriel de récupération non vérifié :", + "Please set your recovery email address to use your email account without restrictions.": "Merci de définir une adresse e-mail de récupération pour bénéficier d'un usage de votre compte sans restrictions.", + "SET RECOVERY EMAIL NOW": "DEFINIR L'ADRESSE DE RECUPERATION MAINTENANT" }, "nplurals=2; plural=n > 1;"); diff --git a/l10n/fr.json b/l10n/fr.json index 40f2a22b84baa4a7bb3c3825401979613847f44c..dc818ef7ca7e5818de8e46d073564891f68a718d 100644 --- a/l10n/fr.json +++ b/l10n/fr.json @@ -22,6 +22,8 @@ "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:": "Courriel de récupération non vérifié :", + "Please set your recovery email address to use your email account without restrictions.": "Merci de définir une adresse e-mail de récupération pour bénéficier d'un usage de votre compte sans restrictions.", + "SET RECOVERY EMAIL NOW": "DEFINIR L'ADRESSE DE RECUPERATION MAINTENANT" },"pluralForm" :"nplurals=2; plural=n > 1;" } \ No newline at end of file diff --git a/l10n/it.js b/l10n/it.js index 48d32cd16240811d0cabfaa5d4ec0d09b4010e56..1d1fe98966c8efa4bebdc066901a9d0a1675997f 100644 --- a/l10n/it.js +++ b/l10n/it.js @@ -24,6 +24,8 @@ OC.L10N.register( "You verified recovery email successfully.": "L'e-mail di recupero è stata verificata con successo.", "Could not verify recovery email because the token is expired": "Impossibile verificare l'email di recupero perché il token è scaduto", "Could not verify recovery email because the token is invalid": "Impossibile verificare l'email di recupero perché il token non è valido", - "Unverified recovery email:": "Email di recupero non verificata:" + "Unverified recovery email:": "Email di recupero non verificata:", + "Please set your recovery email address to use your email account without restrictions.": "Per poter usare l'account email senza restrizioni devi impostare l'indirizzo email di recovery.", + "SET RECOVERY EMAIL NOW": "IMPOSTA ADESSO LA EMAIL DI RECOVERY" }, "nplurals=2; plural=n != 1;"); diff --git a/l10n/it.json b/l10n/it.json index fb26f937796561bf5937ed42cfb5b0acf92f6186..13444723e2349f081291719dfcd8c98f3a060ac3 100644 --- a/l10n/it.json +++ b/l10n/it.json @@ -22,6 +22,8 @@ "You verified recovery email successfully.": "L'e-mail di recupero è stata verificata con successo.", "Could not verify recovery email because the token is expired": "Impossibile verificare l'email di recupero perché il token è scaduto", "Could not verify recovery email because the token is invalid": "Impossibile verificare l'email di recupero perché il token non è valido", - "Unverified recovery email:": "Email di recupero non verificata:" + "Unverified recovery email:": "Email di recupero non verificata:", + "Please set your recovery email address to use your email account without restrictions.": "Per poter usare l'account email senza restrizioni devi impostare l'indirizzo email di recovery.", + "SET RECOVERY EMAIL NOW": "IMPOSTA ADESSO LA EMAIL DI RECOVERY" },"pluralForm" :"nplurals=2; plural=n != 1;" } \ No newline at end of file diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index 5296b1cd0fe704b0631bf18b8dd348f643897884..ca33cdf57682b04a66dc36adbd02e74010116f29 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -30,8 +30,10 @@ use OCP\AppFramework\App; use OCP\AppFramework\Bootstrap\IBootstrap; use OCP\AppFramework\Bootstrap\IRegistrationContext; use OCA\EmailRecovery\Listeners\UserConfigChangedListener; +use OCA\EmailRecovery\Listeners\BeforeTemplateRenderedListener; use OCP\User\Events\UserConfigChangedEvent; use OCP\AppFramework\Bootstrap\IBootContext; +use OCP\AppFramework\Http\Events\BeforeTemplateRenderedEvent; class Application extends App implements IBootstrap { public const APP_ID = 'email-recovery'; @@ -41,6 +43,7 @@ class Application extends App implements IBootstrap { } public function register(IRegistrationContext $context): void { + $context->registerEventListener(BeforeTemplateRenderedEvent::class, BeforeTemplateRenderedListener::class); $context->registerEventListener(UserConfigChangedEvent::class, UserConfigChangedListener::class); } public function boot(IBootContext $context): void { diff --git a/lib/Listeners/BeforeTemplateRenderedListener.php b/lib/Listeners/BeforeTemplateRenderedListener.php new file mode 100644 index 0000000000000000000000000000000000000000..5dee093225b25faaec8a62dc518f8775867047b3 --- /dev/null +++ b/lib/Listeners/BeforeTemplateRenderedListener.php @@ -0,0 +1,42 @@ +appName = $appName; + $this->userId = $userId; + $this->userSession = $userSession; + $this->util = $util; + $this->recoveryEmailService = $recoveryEmailService; + } + + public function handle(Event $event): void { + if (!($event instanceof BeforeTemplateRenderedEvent)) { + return; + } + if ($this->userSession->isLoggedIn() && !empty($this->userId)) { + $recoveryEmail = $this->recoveryEmailService->getRecoveryEmail($this->userId); + if ($recoveryEmail === '') { + $this->util->addStyle($this->appName, 'email-recovery'); + $this->util->addScript($this->appName, $this->appName . '-email-recovery'); + } + } + } +} diff --git a/scss/email-recovery.scss b/scss/email-recovery.scss new file mode 100644 index 0000000000000000000000000000000000000000..4fbf9ae0111c983d1dcad2b158d119a89fbe0d70 --- /dev/null +++ b/scss/email-recovery.scss @@ -0,0 +1,104 @@ +.recovery-email-banner { + display: inline-flex; + position: absolute; + top: 0px; + width: 100%; + z-index: 1000; + min-height: 50px; + box-sizing: border-box; + justify-content: center; + align-items: center; + background: #333333; + color: #ffffff; + font-size: 16px; + font-weight: 400; + line-height: 24px; + padding: 16px 7%; + #recovery-email-banner-container{ + display:inline-flex; + img { + padding-right:10px; + align-self: start; + } + p{ + margin: 0 auto; + } + } + + a { + color: #ffffff; + padding-left: 24px; + text-decoration: underline; + font-size: 16px; + font-weight: 600; + } + +} + +body#body-user #header, +body#body-settings #header, +body#body-public #header { + top: 56px; +} +#header .header-right .header-menu__wrapper{ + top:106px; +} + +#body-user #content, +#body-settings #content, +#body-public #content, +#body-public #content, +#body-user #content-vue { + margin-top: 100px !important; + height: calc(100% - env(safe-area-inset-bottom) - 106px - var(--body-container-margin)); + @media only screen and (min-width: 769px) and (max-width: 1024) { + margin-top: 130px !important; + height: calc(100% - env(safe-area-inset-bottom) - 130px - var(--body-container-margin)); + } + @media only screen and (min-width: 481px) and (max-width: 768px) { + margin-top: 162px !important; + height: calc(100% - env(safe-area-inset-bottom) - 162px - var(--body-container-margin)); + } + @media only screen and (max-width: 399px) { + margin-top: 186px !important; + height: calc(100% - env(safe-area-inset-bottom) - 186px - var(--body-container-margin)); + } + + +} +@media only screen and (max-width: 1024px) { + body#body-user #header, + body#body-settings #header, + body#body-public #header { + top: 80px; + } + #header .header-right .header-menu__wrapper{ + top:130px; + } +} +@media only screen and (max-width: 768px) { + .recovery-email-banner { + display: block; + a{ + padding: 8px 0 0 30px; + } + } + body#body-user #header, + body#body-settings #header, + body#body-public #header { + top: 112px; + } + #header .header-right .header-menu__wrapper{ + top:162px; + } +} +@media only screen and (max-width: 399px) { + body#body-user #header, + body#body-settings #header, + body#body-public #header { + top: 136px; + } + #header .header-right .header-menu__wrapper{ + top:186px; + } +} diff --git a/src/email-recovery.js b/src/email-recovery.js new file mode 100644 index 0000000000000000000000000000000000000000..f8626937d698fe3592807d821004386c0abf8c14 --- /dev/null +++ b/src/email-recovery.js @@ -0,0 +1,70 @@ +import { generateUrl } from '@nextcloud/router' +const APPLICATION_NAME = 'email-recovery' +document.addEventListener('DOMContentLoaded', function() { + const newDiv = createNewDiv('recovery-email-banner') + const contentDiv = document.createElement('div') + contentDiv.id = 'recovery-email-banner-container' + const img = createImageElement(APPLICATION_NAME) + const textNode = createTextNode(APPLICATION_NAME) + const link = createLinkElement(APPLICATION_NAME) + + contentDiv.appendChild(img) + contentDiv.appendChild(textNode) + newDiv.appendChild(contentDiv) + newDiv.appendChild(link) + insertIntoDOM(newDiv) +}) + +/** + * + * @param className + */ +function createNewDiv(className) { + const div = document.createElement('div') + div.className = className + div.id = className + return div +} + +/** + * + * @param appName + */ +function createImageElement(appName) { + const img = document.createElement('img') + img.src = generateUrl('/custom_apps/' + appName + '/img/warning.svg') + return img +} + +/** + * + * @param 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 createLinkElement(appName) { + const link = document.createElement('a') + link.textContent = t(appName, 'SET RECOVERY EMAIL NOW') + link.href = OC.getRootPath() + '/settings/user/security#recovery-email-div' + link.style.display = 'block' + return link +} + +/** + * + * @param element + */ +function insertIntoDOM(element) { + const targetElement = document.getElementById('header') + const parentElement = targetElement.parentNode + parentElement.insertBefore(element, targetElement) +} diff --git a/webpack.config.js b/webpack.config.js index e5daa927a683355f6afe1b51a13235003fe2ada4..02d9f159073577b41aab162c5ce97e2bc04a15e9 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,3 +1,11 @@ const webpackConfig = require('@nextcloud/webpack-vue-config') - +const path = require('path') module.exports = webpackConfig +module.exports = { + ...webpackConfig, + entry: { + 'email-recovery': path.join(__dirname, 'src/email-recovery.js'), + 'main': path.join(__dirname, 'src/main.js') + }, +} +