forked from verdnatura/hedera-web
Add login when password changed
This commit is contained in:
parent
ef36566442
commit
93cc0d4286
|
@ -1,7 +1,6 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, inject, onMounted, nextTick } from 'vue';
|
import { ref, inject, onMounted, nextTick } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { useRouter } from 'vue-router';
|
|
||||||
|
|
||||||
import VnInput from 'src/components/common/VnInput.vue';
|
import VnInput from 'src/components/common/VnInput.vue';
|
||||||
import VnForm from 'src/components/common/VnForm.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 { userStore as useUserStore } from 'stores/user';
|
||||||
import useNotify from 'src/composables/useNotify.js';
|
import useNotify from 'src/composables/useNotify.js';
|
||||||
|
|
||||||
|
const emit = defineEmits(['onPasswordChanged']);
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const api = inject('api');
|
const api = inject('api');
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
const { notify } = useNotify();
|
const { notify } = useNotify();
|
||||||
const router = useRouter();
|
|
||||||
|
|
||||||
const oldPasswordRef = ref(null);
|
const oldPasswordRef = ref(null);
|
||||||
const newPasswordRef = ref(null);
|
const newPasswordRef = ref(null);
|
||||||
|
@ -64,9 +64,13 @@ const getPasswordRequirements = async () => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const logout = async () => {
|
const login = async () => {
|
||||||
await userStore.logout();
|
await userStore.login(userStore.name, formData.value.newPassword);
|
||||||
router.push({ name: 'Login' });
|
};
|
||||||
|
|
||||||
|
const onPasswordChanged = async () => {
|
||||||
|
await login();
|
||||||
|
emit('onPasswordChanged');
|
||||||
};
|
};
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
|
@ -89,7 +93,7 @@ onMounted(async () => {
|
||||||
showBottomActions
|
showBottomActions
|
||||||
:defaultActions="false"
|
:defaultActions="false"
|
||||||
style="max-width: 300px"
|
style="max-width: 300px"
|
||||||
@onDataSaved="logout()"
|
@onDataSaved="onPasswordChanged()"
|
||||||
>
|
>
|
||||||
<template #form>
|
<template #form>
|
||||||
<VnInput
|
<VnInput
|
||||||
|
|
|
@ -103,7 +103,9 @@ onMounted(() => fetchLanguagesSql());
|
||||||
ref="changePasswordFormDialog"
|
ref="changePasswordFormDialog"
|
||||||
v-model="showChangePasswordForm"
|
v-model="showChangePasswordForm"
|
||||||
>
|
>
|
||||||
<ChangePasswordForm />
|
<ChangePasswordForm
|
||||||
|
@on-password-changed="showChangePasswordForm = false"
|
||||||
|
/>
|
||||||
</QDialog>
|
</QDialog>
|
||||||
</QPage>
|
</QPage>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -50,12 +50,13 @@ export const userStore = defineStore('user', {
|
||||||
|
|
||||||
async loadData() {
|
async loadData() {
|
||||||
const userData = await jApi.getObject(
|
const userData = await jApi.getObject(
|
||||||
'SELECT id, nickname FROM account.myUser'
|
'SELECT id, nickname, name FROM account.myUser'
|
||||||
);
|
);
|
||||||
|
|
||||||
this.$patch({
|
this.$patch({
|
||||||
id: userData.id,
|
id: userData.id,
|
||||||
nickname: userData.nickname
|
nickname: userData.nickname,
|
||||||
|
name: userData.name
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue