mirror of
https://github.com/danbulant/Nertivia-Client
synced 2026-07-05 11:00:50 +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: {
|
methods: {
|
||||||
logout() {
|
logout() {
|
||||||
this.$store.dispatch("logout");
|
this.$store.dispatch("logout");
|
||||||
isElectron
|
setTimeout(() => {
|
||||||
? (window.location.href = "/login")
|
isElectron
|
||||||
: (window.location.href = "/");
|
? (window.location.href = "/login")
|
||||||
|
: (window.location.href = "/");
|
||||||
|
}, 1000);
|
||||||
},
|
},
|
||||||
close() {
|
close() {
|
||||||
this.$store.dispatch("setPopoutVisibility", {
|
this.$store.dispatch("setPopoutVisibility", {
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,9 @@ export default {
|
||||||
login(credentials) {
|
login(credentials) {
|
||||||
return wrapper(instance().post("user/login", credentials));
|
return wrapper(instance().post("user/login", credentials));
|
||||||
},
|
},
|
||||||
|
logout() {
|
||||||
|
return wrapper(instance().delete("user/logout"));
|
||||||
|
},
|
||||||
user() {
|
user() {
|
||||||
return wrapper(instance().get("user"));
|
return wrapper(instance().get("user"));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import Vue from "vue";
|
import Vue from "vue";
|
||||||
import NotificationSounds from "@/utils/notificationSound";
|
import NotificationSounds from "@/utils/notificationSound";
|
||||||
|
import AuthenticationService from "@/services/AuthenticationService";
|
||||||
|
|
||||||
const state = {
|
const state = {
|
||||||
token: localStorage.getItem("hauthid") || null,
|
token: localStorage.getItem("hauthid") || null,
|
||||||
|
|
@ -27,8 +28,9 @@ const actions = {
|
||||||
user(context, user) {
|
user(context, user) {
|
||||||
context.commit("user", user);
|
context.commit("user", user);
|
||||||
},
|
},
|
||||||
logout(context) {
|
async logout(context) {
|
||||||
axios.defaults.headers.common["authorization"] = "";
|
axios.defaults.headers.common["authorization"] = "";
|
||||||
|
await AuthenticationService.logout();
|
||||||
localStorage.clear();
|
localStorage.clear();
|
||||||
context.commit("logout");
|
context.commit("logout");
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue