changeset 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 09406e3b052c
children d9ce63cad8da
files client/src/lib/session.js
diffstat 1 files changed, 22 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/client/src/lib/session.js	Wed Sep 11 16:30:25 2019 +0200
+++ b/client/src/lib/session.js	Thu Sep 12 09:23:47 2019 +0200
@@ -14,13 +14,30 @@
 
 import app from "@/main";
 import { unsetLayerConfigs } from "@/components/map/layers";
+import { HTTP } from "@/lib/http";
+import { displayError } from "@/lib/errors";
 
 const logOff = () => {
-  app.$snotify.clear();
-  app.$store.commit("reset");
-  app.$store.commit("user/clearAuth");
-  app.$router.push("/login");
-  unsetLayerConfigs();
+  HTTP.get("/logout", {
+    headers: {
+      "X-Gemma-Auth": localStorage.getItem("token"),
+      "Content-type": "text/xml; charset=UTF-8"
+    }
+  })
+    .then(() => {
+      app.$snotify.clear();
+      app.$store.commit("reset");
+      app.$store.commit("user/clearAuth");
+      app.$router.push("/login");
+      unsetLayerConfigs();
+    })
+    .catch(error => {
+      const { status, data } = error.response;
+      displayError({
+        title: this.$gettext("Backend Error"),
+        message: `${status}: ${data.message || data}`
+      });
+    });
 };
 
 /**