diff --git a/src/components/ui/ChangePasswordForm.vue b/src/components/ui/ChangePasswordForm.vue index b22ad579..eff04318 100644 --- a/src/components/ui/ChangePasswordForm.vue +++ b/src/components/ui/ChangePasswordForm.vue @@ -8,6 +8,13 @@ import VnForm from 'src/components/common/VnForm.vue'; import { userStore as useUserStore } from 'stores/user'; import useNotify from 'src/composables/useNotify.js'; +const props = defineProps({ + verificationToken: { + type: String, + default: '' + } +}); + const emit = defineEmits(['onPasswordChanged']); const { t } = useI18n(); @@ -37,16 +44,16 @@ const changePassword = async () => { notify(t('passwordsDoNotMatch'), 'negative'); throw new Error('Passwords do not match'); } - if (userStore.token) { - await changePasswordWithToken(userStore.token); + if (props.verificationToken) { + await changePasswordWithToken(); } else { await changePasswordWithoutToken(); } }; -const changePasswordWithToken = async token => { +const changePasswordWithToken = async () => { const headers = { - Authorization: token + Authorization: props.verificationToken }; await api.post('VnUsers/reset-password', formData.value, { headers }); }; @@ -76,7 +83,7 @@ const onPasswordChanged = async () => { onMounted(async () => { getPasswordRequirements(); await nextTick(); - if (userStore.token) { + if (props.verificationToken) { newPasswordRef.value.focus(); } else { oldPasswordRef.value.focus(); @@ -97,7 +104,7 @@ onMounted(async () => { >