From d1c035d43ae28c3bc117f89fcc7efba49fe278a5 Mon Sep 17 00:00:00 2001 From: Jannis Mattheis Date: Sun, 11 Nov 2018 20:32:01 +0100 Subject: [PATCH] Remove client on logout --- ui/src/CurrentUser.ts | 10 +++++++++- ui/src/index.tsx | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/ui/src/CurrentUser.ts b/ui/src/CurrentUser.ts index 46ac7fc..6e89e90 100644 --- a/ui/src/CurrentUser.ts +++ b/ui/src/CurrentUser.ts @@ -89,7 +89,15 @@ export class CurrentUser { }); }; - public logout = () => { + public logout = async () => { + await axios + .get(config.get('url') + 'client') + .then((resp: AxiosResponse) => { + resp.data.filter((client) => client.token === this.tokenCache).forEach((client) => { + return axios.delete(config.get('url') + 'client/' + client.id); + }); + }) + .catch(() => Promise.resolve()); window.localStorage.removeItem(tokenKey); this.tokenCache = null; this.loggedIn = false; diff --git a/ui/src/index.tsx b/ui/src/index.tsx index 10604f1..45177cc 100644 --- a/ui/src/index.tsx +++ b/ui/src/index.tsx @@ -87,7 +87,7 @@ const initStores = (): StoreMapping => { } ); - stores.currentUser.tryAuthenticate(); + stores.currentUser.tryAuthenticate().catch(() => {}); ReactDOM.render(