Mercurial > gemma
comparison client/src/lib/session.js @ 4379:f0be2aec953a
logout: Logging out triggers a request to log the user out on server side
author | Thomas Junk <thomas.junk@intevation.de> |
---|---|
date | Thu, 12 Sep 2019 09:23:47 +0200 |
parents | 8775bea8042a |
children | 8dde014af77b |
comparison
equal
deleted
inserted
replaced
4378:09406e3b052c | 4379:f0be2aec953a |
---|---|
12 * Thomas Junk <thomas.junk@intevation.de> | 12 * Thomas Junk <thomas.junk@intevation.de> |
13 */ | 13 */ |
14 | 14 |
15 import app from "@/main"; | 15 import app from "@/main"; |
16 import { unsetLayerConfigs } from "@/components/map/layers"; | 16 import { unsetLayerConfigs } from "@/components/map/layers"; |
17 import { HTTP } from "@/lib/http"; | |
18 import { displayError } from "@/lib/errors"; | |
17 | 19 |
18 const logOff = () => { | 20 const logOff = () => { |
19 app.$snotify.clear(); | 21 HTTP.get("/logout", { |
20 app.$store.commit("reset"); | 22 headers: { |
21 app.$store.commit("user/clearAuth"); | 23 "X-Gemma-Auth": localStorage.getItem("token"), |
22 app.$router.push("/login"); | 24 "Content-type": "text/xml; charset=UTF-8" |
23 unsetLayerConfigs(); | 25 } |
26 }) | |
27 .then(() => { | |
28 app.$snotify.clear(); | |
29 app.$store.commit("reset"); | |
30 app.$store.commit("user/clearAuth"); | |
31 app.$router.push("/login"); | |
32 unsetLayerConfigs(); | |
33 }) | |
34 .catch(error => { | |
35 const { status, data } = error.response; | |
36 displayError({ | |
37 title: this.$gettext("Backend Error"), | |
38 message: `${status}: ${data.message || data}` | |
39 }); | |
40 }); | |
24 }; | 41 }; |
25 | 42 |
26 /** | 43 /** |
27 * Compares whether session is current | 44 * Compares whether session is current |
28 * based on the expiry information and the | 45 * based on the expiry information and the |