fix logging out doesnt work (#1192)

Fixes #1108
This commit is contained in:
Younes
2023-06-12 01:01:49 +01:00
committed by GitHub
parent db9279a6e5
commit 99a4966786

View File

@@ -88,7 +88,7 @@
<span class="title">Moderation</span> <span class="title">Moderation</span>
</NuxtLink> </NuxtLink>
<hr class="divider" /> <hr class="divider" />
<button class="item button-transparent" @click="logout"> <button class="item button-transparent" @click="logout()">
<LogOutIcon class="icon" /> <LogOutIcon class="icon" />
<span class="dropdown-item__text">Log out</span> <span class="dropdown-item__text">Log out</span>
</button> </button>
@@ -162,7 +162,7 @@
</div> </div>
<div class="links"> <div class="links">
<template v-if="auth.user"> <template v-if="auth.user">
<button class="iconified-button danger-button" @click="logout"> <button class="iconified-button danger-button" @click="logout()">
<LogOutIcon aria-hidden="true" /> <LogOutIcon aria-hidden="true" />
Log out Log out
</button> </button>
@@ -471,27 +471,21 @@ export default defineNuxtComponent({
this.isMobileMenuOpen = false this.isMobileMenuOpen = false
} }
}, },
async logout() { logout() {
useCookie('auth-token').value = null useCookie('auth-token').value = null
// If users logs out on dashboard, force redirect on the home page to clear cookies this.$notify({
if ( group: 'main',
this.$route.path.startsWith('/settings/') || title: 'Logged Out',
this.$route.path.startsWith('/dashboard/') || text: 'You have logged out successfully!',
this.$route.path.startsWith('/moderation') || type: 'success',
this.$route.path.startsWith('/notifications') })
) {
window.location.href = '/'
} else {
await this.$router.go(null)
this.$notify({ useRouter()
group: 'main', .push('/')
title: 'Logged Out', .then(() => {
text: 'You have logged out successfully!', useRouter().go()
type: 'success',
}) })
}
}, },
changeTheme() { changeTheme() {
this.isThemeSwitchOnHold = true this.isThemeSwitchOnHold = true