From f8a1936f3e4e5f3182804353238b853f39b7c9d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Glasn=C3=A1k?= Date: Thu, 30 Mar 2023 13:20:51 +0200 Subject: [PATCH 1/3] [Reset password] Implemented reset password --- app/src/plugins/app/_config/router.ts | 10 ++++++-- .../app/_layout/auth/_components/a-header.vue | 4 ++-- .../_components/a-forgot-password-form.vue | 3 +-- .../forgot-success/forgot-success.vue | 23 +++++++++++++++++++ .../login/_components/a-login-form.vue | 2 +- .../_components/a-reset-password-form.vue | 22 +++++++++--------- app/src/plugins/w/auth/auth.store.ts | 7 +++++- 7 files changed, 52 insertions(+), 19 deletions(-) create mode 100644 app/src/plugins/lib@auth/forgot-success/forgot-success.vue diff --git a/app/src/plugins/app/_config/router.ts b/app/src/plugins/app/_config/router.ts index e4c1a2f..d62d3d1 100644 --- a/app/src/plugins/app/_config/router.ts +++ b/app/src/plugins/app/_config/router.ts @@ -26,11 +26,17 @@ const routes: Array = [ component: () => import('@/plugins/lib@auth/forgot-password/forgot-password.vue'), meta: {requiresAuth: false} }, + { + path: '/auth/forgot-success', + name: 'Forgot success', + component: () => import('@/plugins/lib@auth/forgot-success/forgot-success.vue'), + meta: {requiresAuth: false} + }, { path: '/auth/reset-password', name: 'Reset password', component: () => import('@/plugins/lib@auth/reset-password/reset-password.vue'), - meta: {requiresAuth: false} + meta: {requiresAuth: null} } ] }, @@ -126,7 +132,7 @@ router.beforeEach((to, from, next) => { else return next({name: 'Dashboard - Tasks'}) } else { - return next({name: 'Login'}) + return next() } }) diff --git a/app/src/plugins/app/_layout/auth/_components/a-header.vue b/app/src/plugins/app/_layout/auth/_components/a-header.vue index b99d759..7ecf9c1 100644 --- a/app/src/plugins/app/_layout/auth/_components/a-header.vue +++ b/app/src/plugins/app/_layout/auth/_components/a-header.vue @@ -1,7 +1,7 @@ diff --git a/app/src/plugins/lib@auth/forgot-password/_components/a-forgot-password-form.vue b/app/src/plugins/lib@auth/forgot-password/_components/a-forgot-password-form.vue index 1c9f622..2f7c4fe 100644 --- a/app/src/plugins/lib@auth/forgot-password/_components/a-forgot-password-form.vue +++ b/app/src/plugins/lib@auth/forgot-password/_components/a-forgot-password-form.vue @@ -45,8 +45,7 @@ export default { try { await this.$store.dispatch('auth/forgotPassword', this.credentials) - this.$router.push({name: 'Reset password', query: {email: this.credentials.email}}) - this.$toast.success('Reset code has been sent to your email.') + this.$router.push({name: 'Forgot success', query: {email: this.credentials.email}}) } catch (error) { this.$toast.error(error) } diff --git a/app/src/plugins/lib@auth/forgot-success/forgot-success.vue b/app/src/plugins/lib@auth/forgot-success/forgot-success.vue new file mode 100644 index 0000000..2c0f012 --- /dev/null +++ b/app/src/plugins/lib@auth/forgot-success/forgot-success.vue @@ -0,0 +1,23 @@ + + + diff --git a/app/src/plugins/lib@auth/login/_components/a-login-form.vue b/app/src/plugins/lib@auth/login/_components/a-login-form.vue index 86eadde..0d666a9 100644 --- a/app/src/plugins/lib@auth/login/_components/a-login-form.vue +++ b/app/src/plugins/lib@auth/login/_components/a-login-form.vue @@ -49,7 +49,7 @@ export default { await this.$store.dispatch('auth/login', this.form) this.$router.push({ name: 'Dashboard - Tasks'}) } catch (error) { - this.$toast.error(error) + this.$toast.error(error?.response?.data?.message || error) } } } diff --git a/app/src/plugins/lib@auth/reset-password/_components/a-reset-password-form.vue b/app/src/plugins/lib@auth/reset-password/_components/a-reset-password-form.vue index 57a390b..6699710 100644 --- a/app/src/plugins/lib@auth/reset-password/_components/a-reset-password-form.vue +++ b/app/src/plugins/lib@auth/reset-password/_components/a-reset-password-form.vue @@ -1,23 +1,19 @@