Change query logout to mutation, call of mutation instead of query.

This commit is contained in:
elweyn 2022-09-22 11:54:36 +02:00
parent 2d4f88ce84
commit 4fdc492a6c
3 changed files with 11 additions and 9 deletions

View File

@ -154,3 +154,9 @@ export const login = gql`
}
}
`
export const logout = gql`
mutation {
logout
}
`

View File

@ -18,12 +18,6 @@ export const verifyLogin = gql`
}
`
export const logout = gql`
query {
logout
}
`
export const transactionsQuery = gql`
query($currentPage: Int = 1, $pageSize: Int = 25, $order: Order = DESC) {
transactionList(currentPage: $currentPage, pageSize: $pageSize, order: $order) {

View File

@ -41,7 +41,8 @@
import Navbar from '@/components/Menu/Navbar.vue'
import Sidebar from '@/components/Menu/Sidebar.vue'
import SessionLogoutTimeout from '@/components/SessionLogoutTimeout.vue'
import { logout, transactionsQuery } from '@/graphql/queries'
import { transactionsQuery } from '@/graphql/queries'
import { logout } from '@/graphql/mutations'
import ContentFooter from '@/components/ContentFooter.vue'
import { FadeTransition } from 'vue2-transitions'
import CONFIG from '@/config'
@ -75,14 +76,15 @@ export default {
methods: {
async logout() {
this.$apollo
.query({
query: logout,
.mutate({
mutation: logout,
})
.then(() => {
this.$store.dispatch('logout')
this.$router.push('/login')
})
.catch(() => {
console.log('TESTTEST')
this.$store.dispatch('logout')
if (this.$router.currentRoute.path !== '/login') this.$router.push('/login')
})