logout method
This commit is contained in:
parent
2882b64d25
commit
a9933ccc8e
@ -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,8 +586,17 @@ 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();
|
||||
this.getMissions();
|
||||
@ -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>
|
||||
@ -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,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user