remove loginAPI calls from store

This commit is contained in:
Moriz Wahl 2021-04-21 16:51:46 +02:00
parent 4a8ba8d385
commit 810bd6d0ba
4 changed files with 11 additions and 7 deletions

View File

@ -70,7 +70,6 @@
<script> <script>
import NavbarToggleButton from '@/components/NavbarToggleButton' import NavbarToggleButton from '@/components/NavbarToggleButton'
import VueQrcode from 'vue-qrcode' import VueQrcode from 'vue-qrcode'
import loginAPI from '../../apis/loginAPI'
export default { export default {
name: 'sidebar', name: 'sidebar',
@ -102,10 +101,8 @@ export default {
showSidebar() { showSidebar() {
this.$sidebar.displaySidebar(true) this.$sidebar.displaySidebar(true)
}, },
async logout() { logout() {
//const result = await loginAPI.logout(this.$store.state.session_id) this.$emit('logout')
this.$store.dispatch('logout')
this.$router.push('/login')
}, },
}, },
} }

View File

@ -1,7 +1,6 @@
import Vue from 'vue' import Vue from 'vue'
import Vuex from 'vuex' import Vuex from 'vuex'
Vue.use(Vuex) Vue.use(Vuex)
import loginAPI from '../apis/loginAPI'
import communityAPI from '../apis/communityAPI' import communityAPI from '../apis/communityAPI'
import createPersistedState from 'vuex-persistedstate' import createPersistedState from 'vuex-persistedstate'

View File

@ -1,7 +1,7 @@
<template> <template>
<div class="wrapper"> <div class="wrapper">
<notifications></notifications> <notifications></notifications>
<side-bar> <side-bar @logout="logout">
<template slot="links"> <template slot="links">
<b-nav-item href="#!" to="/overview"> <b-nav-item href="#!" to="/overview">
<b-nav-text class="p-0 text-lg text-muted">{{ $t('send') }}</b-nav-text> <b-nav-text class="p-0 text-lg text-muted">{{ $t('send') }}</b-nav-text>
@ -36,6 +36,7 @@
<script> <script>
import PerfectScrollbar from 'perfect-scrollbar' import PerfectScrollbar from 'perfect-scrollbar'
import 'perfect-scrollbar/css/perfect-scrollbar.css' import 'perfect-scrollbar/css/perfect-scrollbar.css'
import loginAPI from '../../apis/loginAPI'
function hasElement(className) { function hasElement(className) {
return document.getElementsByClassName(className).length > 0 return document.getElementsByClassName(className).length > 0
@ -71,6 +72,12 @@ export default {
initScrollbar('sidenav') initScrollbar('sidenav')
} }
}, },
async logout() {
const result = await loginAPI.logout(this.$store.state.session_id)
// do we have to check success?
this.$store.dispatch('logout')
this.$router.push('/login')
},
}, },
mounted() { mounted() {
this.initScrollbar() this.initScrollbar()

View File

@ -28,6 +28,7 @@
<script> <script>
import { BaseNav } from '@/components' import { BaseNav } from '@/components'
import VueQrcode from 'vue-qrcode' import VueQrcode from 'vue-qrcode'
import loginAPI from '../../apis/loginAPI'
export default { export default {
components: { components: {