Skip to content

Commit

Permalink
fix: logout
Browse files Browse the repository at this point in the history
  • Loading branch information
WDaan committed Apr 13, 2023
1 parent bb19936 commit ce86365
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "vuetorrent",
"version": "1.5.3",
"scripts": {
"start": "vite build --watch",
"start": "vite --host",
"dev": "vite -d",
"build": "run-p type-check build-only",
"preview": "vite preview",
Expand Down
6 changes: 5 additions & 1 deletion src/components/Navbar/BottomActions.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<script setup lang="ts">
import { mdiExitToApp } from '@mdi/js'
import { useAuthStore } from '@/stores/auth'
const authStore = useAuthStore()
</script>

<template>
Expand All @@ -8,9 +11,10 @@ import { mdiExitToApp } from '@mdi/js'
<VTooltip>
<template #activator="{ props }">
<div class="d-flex justify-center fill-height">
<VIcon v-bind="props" :icon="mdiExitToApp" />
<VIcon v-bind="props" :icon="mdiExitToApp" @click="authStore.logout()" />
</div>
</template>
<span>{{ $t('logout') }}</span>
</VTooltip>
</VCol>
</VRow>
Expand Down
6 changes: 3 additions & 3 deletions src/composables/api/info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useAxios } from '@vueuse/integrations/useAxios'
import { axiosInstance } from '@/services/qbit'
import type { MainDataResponse, SessionInfoResponse } from '@/types/qbit/responses'

const pollinRate = 1000
const pollingRate = 1000

export const useSessionInfo = () => {
return useQuery({
Expand All @@ -12,7 +12,7 @@ export const useSessionInfo = () => {
const { data } = await useAxios<SessionInfoResponse>('/transfer/info', axiosInstance)
return data.value
},
refetchInterval: pollinRate
refetchInterval: pollingRate
})
}

Expand All @@ -28,6 +28,6 @@ export const useMainData = (rid?: number) => {

return data.value
},
refetchInterval: pollinRate
refetchInterval: pollingRate
})
}
12 changes: 5 additions & 7 deletions src/stores/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,12 @@ export const useAuthStore = defineStore('auth', () => {
}

const logout = async () => {
const { data } = useAxios('/auth/logout', { method: 'POST' }, axiosInstance)
console.log(data.value)
if (data.value === 'Ok.') {
toast.success(i18n.t('toast.logoutSuccess'.toString()))
isAuthenticated.value = false
router.push('/login')
}
useAxios('/auth/logout', { method: 'POST' }, axiosInstance)
toast.success(i18n.t('toast.logoutSuccess'.toString()))
isAuthenticated.value = false
router.push('/login')
}

const checkAuth = async () => {
const res = await axios
.get('/api/v2/app/version')
Expand Down

0 comments on commit ce86365

Please sign in to comment.