mirror of
https://github.com/danbulant/Nertivia-Client
synced 2026-06-18 05:51:11 +00:00
added logout service
This commit is contained in:
parent
58896f832c
commit
abd0733ad1
3 changed files with 11 additions and 4 deletions
|
|
@ -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", {
|
||||
|
|
|
|||
|
|
@ -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"));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in a new issue