Add verificationToken as a prop to let the view handle it
gitea/hedera-web/pipeline/pr-4922-vueMigration This commit looks good
Details
gitea/hedera-web/pipeline/pr-4922-vueMigration This commit looks good
Details
This commit is contained in:
parent
93cc0d4286
commit
4256f45373
|
@ -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 () => {
|
|||
>
|
||||
<template #form>
|
||||
<VnInput
|
||||
v-if="!userStore.token"
|
||||
v-if="!verificationToken"
|
||||
ref="oldPasswordRef"
|
||||
v-model="formData.oldPassword"
|
||||
:label="t('oldPassword')"
|
||||
|
|
Loading…
Reference in New Issue