Remove client on logout

This commit is contained in:
Jannis Mattheis 2018-11-11 20:32:01 +01:00
parent 887328ee65
commit d1c035d43a
2 changed files with 10 additions and 2 deletions

View File

@ -89,7 +89,15 @@ export class CurrentUser {
});
};
public logout = () => {
public logout = async () => {
await axios
.get(config.get('url') + 'client')
.then((resp: AxiosResponse<IClient[]>) => {
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;

View File

@ -87,7 +87,7 @@ const initStores = (): StoreMapping => {
}
);
stores.currentUser.tryAuthenticate();
stores.currentUser.tryAuthenticate().catch(() => {});
ReactDOM.render(
<InjectProvider stores={stores}>