From 38e227a9d4860ef8771c9b49ce8f40281e3e00df Mon Sep 17 00:00:00 2001 From: Divlo Date: Mon, 29 Aug 2022 20:15:47 +0200 Subject: [PATCH] feat: add button to sign out to all connected devices --- .../Application/UserSettings/UserSettings.tsx | 19 ++++++++++++------- locales/en/application.json | 1 + locales/fr/application.json | 1 + tools/authentication/Authentication.ts | 7 +++++++ 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/components/Application/UserSettings/UserSettings.tsx b/components/Application/UserSettings/UserSettings.tsx index 4ab3414..2e9e30c 100644 --- a/components/Application/UserSettings/UserSettings.tsx +++ b/components/Application/UserSettings/UserSettings.tsx @@ -170,13 +170,13 @@ export const UserSettings: React.FC = () => { } const handleSignout = async (): Promise => { - try { - setFetchState('loading') - await authentication.signoutServerSide() - } catch (error) { - setFetchState('error') - setMessage('errors:server-error') - } + setFetchState('loading') + await authentication.signoutServerSide() + } + + const handleSignoutAllDevices = async (): Promise => { + setFetchState('loading') + await authentication.signoutAllDevicesServerSide() } const handleDeletionProvider = ( @@ -375,6 +375,11 @@ export const UserSettings: React.FC = () => { {t('application:signout')} +
+ +
{ + try { + await this.api.delete('/users/signout') + } catch {} + this.signout() + } + public signin(): void { cookies.set('refreshToken', this.tokens.refreshToken) }