diff --git a/src/router/index.ts b/src/router/index.ts index 0c3e004..c2d4384 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -26,10 +26,22 @@ const resetGuard = async (to: any, from: any, next: any) => { const authStore = useAuthStore() if (authStore.requirePasswordChange) { next('/resetPassword') + return; } next() }; +const forgotPassword = async (to: any, from: any, next: any) => { + const authStore = useAuthStore() + + if (from.path !== '/login' && authStore.isAuthenticated) { + next('/') + return; + } + next() + return; +}; + const routes: Array = [ { path: '/', diff --git a/src/services/UserService.ts b/src/services/UserService.ts index a5080b4..82413e3 100644 --- a/src/services/UserService.ts +++ b/src/services/UserService.ts @@ -50,7 +50,7 @@ const resetPassword = async(params: any) : Promise => { const forgotPassword = async(params: any) : Promise => { return api({ - url: "service/sendResetPasswordMailToPartyV2", + url: "/sendResetPassword", method: "post", data: params }) diff --git a/src/views/ForgotPassword.vue b/src/views/ForgotPassword.vue index 8ae8aac..dae1d58 100644 --- a/src/views/ForgotPassword.vue +++ b/src/views/ForgotPassword.vue @@ -7,11 +7,11 @@
{{ $t("Username") }} - + {{ $t("Email") }} - +
@@ -26,13 +26,19 @@ - + {{ $t(successMessage) }}
{{ $t('Login') }} + + + + + + @@ -42,6 +48,8 @@ import { IonButton, IonContent, + IonFab, + IonFabButton, IonIcon, IonInput, IonItem, @@ -52,7 +60,7 @@ import { defineComponent } from "vue"; import { useRouter } from "vue-router"; import { useAuthStore } from "@/store/auth"; import Logo from '@/components/Logo.vue'; -import { checkmarkCircleOutline, closeCircleOutline } from 'ionicons/icons' +import { checkmarkCircleOutline, closeCircleOutline, gridOutline } from 'ionicons/icons' import { hasError } from "@/adapter"; import { UserService } from "@/services/UserService" @@ -61,6 +69,8 @@ export default defineComponent({ components: { IonButton, IonContent, + IonFab, + IonFabButton, IonIcon, IonInput, IonItem, @@ -80,12 +90,10 @@ export default defineComponent({ // clearning the data on page leave this.username = '' this.email = '' - this.errorMessage = '' - this.successMessage = '' + this.clearMessages(); }, methods: { async forgotPassword() { - if(!this.username.trim() || !this.email.trim()) { this.errorMessage = 'Username or Email cannot be empty, please fill both the fields.' return; @@ -108,6 +116,10 @@ export default defineComponent({ this.errorMessage = 'Failed to send password reset link, please try again or contact administrator.' console.error(err) } + }, + clearMessages() { + this.errorMessage = '' + this.successMessage = '' } }, setup () { @@ -117,6 +129,7 @@ export default defineComponent({ authStore, checkmarkCircleOutline, closeCircleOutline, + gridOutline, router }; } diff --git a/src/views/Login.vue b/src/views/Login.vue index cb2c815..98766b5 100644 --- a/src/views/Login.vue +++ b/src/views/Login.vue @@ -41,10 +41,10 @@ -

{{ errorMessage }}

+

{{ errorMessage }}

-

{{ $t('Forgot Password?') }}

+

{{ $t('Forgot Password?') }}

diff --git a/src/views/ResetPassword.vue b/src/views/ResetPassword.vue index c2f1574..1e54a12 100644 --- a/src/views/ResetPassword.vue +++ b/src/views/ResetPassword.vue @@ -5,17 +5,18 @@