Fix logout

This commit is contained in:
Mulia Nasution 2023-06-05 10:56:39 +07:00
parent a44bd3b050
commit 05b665087a
2 changed files with 6 additions and 13 deletions

View File

@ -1,8 +1,5 @@
import * as Forge from 'node-forge' import * as Forge from 'node-forge'
import axios from 'axios' import axios from 'axios'
import { useRouter } from 'vue-router'
const router = useRouter()
export default { export default {
_user: null, _user: null,
@ -72,7 +69,6 @@ export default {
window.localStorage.removeItem('refresh_token'); window.localStorage.removeItem('refresh_token');
await axios.post('authentication/logout') await axios.post('authentication/logout')
axios.defaults.headers['authorization'] = null; axios.defaults.headers['authorization'] = null;
router.push({ name: 'login-form' })
}, },
async getUser() { async getUser() {

View File

@ -41,7 +41,7 @@
</div> </div>
</template> </template>
</dx-item> </dx-item>
<template #menuUserItem> <template #menuUserItem>
<user-panel <user-panel
:email="email" :email="email"
@ -75,7 +75,7 @@ export default {
const email = ref(""); const email = ref("");
auth.getUser().then((e) => email.value = e.data.email); auth.getUser().then((e) => email.value = e.data.email);
const userMenuItems = [{ const userMenuItems = [{
text: "Profile", text: "Profile",
icon: "user", icon: "user",
@ -86,13 +86,10 @@ export default {
icon: "runner", icon: "runner",
onClick: onLogoutClick onClick: onLogoutClick
}]; }];
function onLogoutClick() { async function onLogoutClick() {
auth.logOut(); await auth.logOut();
router.push({ router.push({name: 'login-form'});
path: "/login-form",
query: { redirect: route.path }
});
} }
function onProfileClick() { function onProfileClick() {