logout method

This commit is contained in:
='fauz 2025-10-20 11:41:55 +07:00
parent 2882b64d25
commit a9933ccc8e
2 changed files with 11 additions and 12 deletions

View File

@ -354,6 +354,7 @@
import { getContent } from '@/services/content';
import { getMissions,getMissionLogs, createMissionLog } from '@/services/missions';
import { useAuthStore } from '@/stores/auth'
import { nextTick } from 'vue';
export default {
name: "App",
@ -585,7 +586,16 @@ export default {
});
mission.userStatus = 'in_progress';
}
},
async handleLogout() {
try {
await this.authStore.logout();
await nextTick();
this.$router.push("/login");
} catch (err) {
console.error("Logout failed:", err);
}
},
},
mounted() {
this.getMission();
@ -606,13 +616,3 @@ export default {
}
};
</script>
<script setup>
// import { useAuthStore } from '@/stores/auth'
import { useRouter } from 'vue-router'
const router = useRouter()
const auth = useAuthStore()
const handleLogout = () => {
auth.logout()
router.push('/login')
}
</script>

View File

@ -55,7 +55,6 @@ export const useAuthStore = defineStore('auth', {
console.log("✅ Logged in as:", this.user.username);
},
async logout() {
// revoke token
if(this.token){
await axios.post(this.baseUrl + '/oauth/revoke_token/', {
token: this.token,