API call for logout in compomemt

This commit is contained in:
Moriz Wahl 2021-04-21 16:24:06 +02:00
parent 72517bc999
commit 4a8ba8d385
3 changed files with 8 additions and 41 deletions

View File

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

View File

@ -49,23 +49,19 @@ export const store = new Vuex.Store({
},
},
actions: {
login: async ({ dispatch, commit }, data) => {
login: ({ dispatch, commit }, data) => {
commit('session_id', data.session_id)
commit('email', data.email)
},
passwordReset: async (data) => {},
schoepfen: async (data) => {
passwordReset: (data) => {},
schoepfen: (data) => {
// http://localhost/transaction-creations/ajaxCreate
},
createUser: async ({ commit, dispatch }, data) => {
createUser: ({ commit, dispatch }, data) => {
commit('session_id', data.session_id)
commit('email', data.email)
},
logout: async ({ commit, state }) => {
if (state.session_id) {
const result = await loginAPI.logout(state.session_id)
// The result can be error, but thats ok with us
}
logout: ({ commit, state }) => {
commit('session_id', null)
commit('email', null)
sessionStorage.clear()

View File

@ -37,37 +37,6 @@ export default {
props: {
type: {
type: String,
default: 'default', // default|light
description: 'Look of the dashboard navbar. Default (Green) or light (gray)',
},
},
computed: {
routeName() {
const { name } = this.$route
return this.capitalizeFirstLetter(name)
},
},
data() {
return {
activeNotifications: false,
showMenu: false,
searchModalVisible: false,
searchQuery: '',
}
},
methods: {
capitalizeFirstLetter(string) {
return string.charAt(0).toUpperCase() + string.slice(1)
},
toggleNotificationDropDown() {
this.activeNotifications = !this.activeNotifications
},
closeDropDown() {
this.activeNotifications = false
},
logout() {
this.$store.dispatch('logout')
this.$router.push('/login')
},
},
}