0
1
Fork 0

Add login when password changed

This commit is contained in:
William Buezas 2024-07-26 09:25:46 -03:00
parent ef36566442
commit 93cc0d4286
3 changed files with 16 additions and 9 deletions

View File

@ -1,7 +1,6 @@
<script setup>
import { ref, inject, onMounted, nextTick } from 'vue';
import { useI18n } from 'vue-i18n';
import { useRouter } from 'vue-router';
import VnInput from 'src/components/common/VnInput.vue';
import VnForm from 'src/components/common/VnForm.vue';
@ -9,11 +8,12 @@ import VnForm from 'src/components/common/VnForm.vue';
import { userStore as useUserStore } from 'stores/user';
import useNotify from 'src/composables/useNotify.js';
const emit = defineEmits(['onPasswordChanged']);
const { t } = useI18n();
const api = inject('api');
const userStore = useUserStore();
const { notify } = useNotify();
const router = useRouter();
const oldPasswordRef = ref(null);
const newPasswordRef = ref(null);
@ -64,9 +64,13 @@ const getPasswordRequirements = async () => {
}
};
const logout = async () => {
await userStore.logout();
router.push({ name: 'Login' });
const login = async () => {
await userStore.login(userStore.name, formData.value.newPassword);
};
const onPasswordChanged = async () => {
await login();
emit('onPasswordChanged');
};
onMounted(async () => {
@ -89,7 +93,7 @@ onMounted(async () => {
showBottomActions
:defaultActions="false"
style="max-width: 300px"
@onDataSaved="logout()"
@onDataSaved="onPasswordChanged()"
>
<template #form>
<VnInput

View File

@ -103,7 +103,9 @@ onMounted(() => fetchLanguagesSql());
ref="changePasswordFormDialog"
v-model="showChangePasswordForm"
>
<ChangePasswordForm />
<ChangePasswordForm
@on-password-changed="showChangePasswordForm = false"
/>
</QDialog>
</QPage>
</template>

View File

@ -50,12 +50,13 @@ export const userStore = defineStore('user', {
async loadData() {
const userData = await jApi.getObject(
'SELECT id, nickname FROM account.myUser'
'SELECT id, nickname, name FROM account.myUser'
);
this.$patch({
id: userData.id,
nickname: userData.nickname
nickname: userData.nickname,
name: userData.name
});
}
}