added logout service

This commit is contained in:
unknown 2019-12-26 09:56:58 +00:00
parent 58896f832c
commit abd0733ad1
3 changed files with 11 additions and 4 deletions

View file

@ -99,9 +99,11 @@ export default {
methods: {
logout() {
this.$store.dispatch("logout");
isElectron
? (window.location.href = "/login")
: (window.location.href = "/");
setTimeout(() => {
isElectron
? (window.location.href = "/login")
: (window.location.href = "/");
}, 1000);
},
close() {
this.$store.dispatch("setPopoutVisibility", {

View file

@ -7,6 +7,9 @@ export default {
login(credentials) {
return wrapper(instance().post("user/login", credentials));
},
logout() {
return wrapper(instance().delete("user/logout"));
},
user() {
return wrapper(instance().get("user"));
}

View file

@ -1,6 +1,7 @@
import axios from "axios";
import Vue from "vue";
import NotificationSounds from "@/utils/notificationSound";
import AuthenticationService from "@/services/AuthenticationService";
const state = {
token: localStorage.getItem("hauthid") || null,
@ -27,8 +28,9 @@ const actions = {
user(context, user) {
context.commit("user", user);
},
logout(context) {
async logout(context) {
axios.defaults.headers.common["authorization"] = "";
await AuthenticationService.logout();
localStorage.clear();
context.commit("logout");
},