From a46198e2d0170cd7ae3c41619d54f34b88967c12 Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 13 Aug 2024 12:25:08 +0200 Subject: [PATCH] feat: add recover password and reset password --- src/components/ui/VnOutForm.vue | 32 ++++++++++ src/i18n/locale/en.yml | 16 +++-- src/i18n/locale/es.yml | 16 +++-- src/pages/Login/LoginMain.vue | 15 ++++- src/pages/Login/RecoverPassword.vue | 59 +++++++++++++++++ src/pages/Login/ResetPassword.vue | 99 +++++++++++++++++++++++++++++ src/pages/Login/TwoFactor.vue | 51 ++++++--------- src/router/index.js | 2 +- src/router/routes.js | 12 ++++ 9 files changed, 256 insertions(+), 46 deletions(-) create mode 100644 src/components/ui/VnOutForm.vue create mode 100644 src/pages/Login/RecoverPassword.vue create mode 100644 src/pages/Login/ResetPassword.vue diff --git a/src/components/ui/VnOutForm.vue b/src/components/ui/VnOutForm.vue new file mode 100644 index 000000000..b44445682 --- /dev/null +++ b/src/components/ui/VnOutForm.vue @@ -0,0 +1,32 @@ + + + diff --git a/src/i18n/locale/en.yml b/src/i18n/locale/en.yml index 12680d0cb..ee53da80c 100644 --- a/src/i18n/locale/en.yml +++ b/src/i18n/locale/en.yml @@ -251,6 +251,9 @@ globals: privileges: Privileges ldap: LDAP samba: Samba + twoFactor: Two factor + recoverPassword: Recover password + resetPassword: Reset password created: Created worker: Worker now: Now @@ -288,14 +291,17 @@ twoFactor: explanation: >- Please, enter the verification code that we have sent to your email in the next 5 minutes - pageTitles: - twoFactor: Two-Factor verifyEmail: pageTitles: verifyEmail: Email verification -dashboard: - pageTitles: - +recoverPassword: + userOrEmail: User or recovery email + explanation: >- + We will sent you an email to recover your password +resetPassword: + repeatPassword: Repeat password + passwordNotMatch: Passwords don't match + passwordChanged: Password changed customer: list: phone: Phone diff --git a/src/i18n/locale/es.yml b/src/i18n/locale/es.yml index 747a10d51..71e227fbd 100644 --- a/src/i18n/locale/es.yml +++ b/src/i18n/locale/es.yml @@ -253,6 +253,9 @@ globals: packages: Bultos ldap: LDAP samba: Samba + twoFactor: Doble factor + recoverPassword: Recuperar contraseña + resetPassword: Restablecer contraseña created: Fecha creación worker: Trabajador now: Ahora @@ -289,14 +292,17 @@ twoFactor: validate: Validar insert: Introduce el código de verificación explanation: Por favor introduce el código de verificación que te hemos enviado a tu email en los próximos 5 minutos - pageTitles: - twoFactor: Doble factor verifyEmail: pageTitles: verifyEmail: Verificación de correo -dashboard: - pageTitles: - +recoverPassword: + userOrEmail: Usuario o correo de recuperación + explanation: >- + Te enviaremos un correo para restablecer tu contraseña +resetPassword: + repeatPassword: Repetir contraseña + passwordNotMatch: Las contraseñas no coinciden + passwordChanged: Contraseña cambiada customer: list: phone: Teléfono diff --git a/src/pages/Login/LoginMain.vue b/src/pages/Login/LoginMain.vue index 4eb21f573..c17201969 100644 --- a/src/pages/Login/LoginMain.vue +++ b/src/pages/Login/LoginMain.vue @@ -72,7 +72,8 @@ async function onSubmit() { :rules="[(val) => (val && val.length > 0) || t('login.fieldRequired')]" class="red" /> -
+ +
+ + {{ t('I do not remember my password') }} +
- - + +es: + I do not remember my password: No recuerdo mi contraseña + diff --git a/src/pages/Login/RecoverPassword.vue b/src/pages/Login/RecoverPassword.vue new file mode 100644 index 000000000..5e0fd367a --- /dev/null +++ b/src/pages/Login/RecoverPassword.vue @@ -0,0 +1,59 @@ + + diff --git a/src/pages/Login/ResetPassword.vue b/src/pages/Login/ResetPassword.vue new file mode 100644 index 000000000..eff718e97 --- /dev/null +++ b/src/pages/Login/ResetPassword.vue @@ -0,0 +1,99 @@ + + diff --git a/src/pages/Login/TwoFactor.vue b/src/pages/Login/TwoFactor.vue index 31b4ccc79..dd404094f 100644 --- a/src/pages/Login/TwoFactor.vue +++ b/src/pages/Login/TwoFactor.vue @@ -8,6 +8,7 @@ import axios from 'axios'; import { useSession } from 'src/composables/useSession'; import { useLogin } from 'src/composables/useLogin'; import VnInput from 'src/components/common/VnInput.vue'; +import VnOutForm from 'src/components/ui/VnOutForm.vue'; const quasar = useQuasar(); const session = useSession(); @@ -38,24 +39,22 @@ async function onSubmit() { } - diff --git a/src/router/index.js b/src/router/index.js index faa3ab5d4..686da2dde 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -46,7 +46,7 @@ export { Router }; export default route(function (/* { store, ssrContext } */) { Router.beforeEach(async (to, from, next) => { const { isLoggedIn } = session; - const outLayout = ['Login', 'TwoFactor', 'VerifyEmail']; + const outLayout = Router.options.routes[0].children.map((r) => r.name); if (!isLoggedIn() && !outLayout.includes(to.name)) { return next({ name: 'Login', query: { redirect: to.fullPath } }); } diff --git a/src/router/routes.js b/src/router/routes.js index 805eefb8c..cced308b5 100644 --- a/src/router/routes.js +++ b/src/router/routes.js @@ -46,6 +46,18 @@ const routes = [ meta: { title: 'verifyEmail' }, component: () => import('../pages/Login/VerifyEmail.vue'), }, + { + path: '/recoverPassword', + name: 'RecoverPassword', + meta: { title: 'recoverPassword' }, + component: () => import('../pages/Login/RecoverPassword.vue'), + }, + { + path: '/resetPassword', + name: 'ResetPassword', + meta: { title: 'resetPassword' }, + component: () => import('../pages/Login/ResetPassword.vue'), + }, ], }, {