From 281829a4732e9bd305d80edcce4c6ae72509b396 Mon Sep 17 00:00:00 2001 From: Gabe Kangas Date: Wed, 25 May 2022 22:51:17 -0700 Subject: [PATCH] Support re-authing on invalid access token --- web/components/stores/ClientConfigStore.tsx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/web/components/stores/ClientConfigStore.tsx b/web/components/stores/ClientConfigStore.tsx index 19dd0338f..7abae4170 100644 --- a/web/components/stores/ClientConfigStore.tsx +++ b/web/components/stores/ClientConfigStore.tsx @@ -175,15 +175,24 @@ export function ClientConfigStore() { setAccessToken(newAccessToken); setLocalStorage(ACCESS_TOKEN_KEY, newAccessToken); setChatDisplayName(newDisplayName); - // sendEvent(AppStateEvent.Registered); } catch (e) { sendEvent(AppStateEvent.Fail); console.error(`ChatService -> registerUser() ERROR: \n${e}`); } }; + const resetAndReAuth = () => { + console.log('!!!!! reauth!!'); + setLocalStorage(ACCESS_TOKEN_KEY, ''); + setAccessToken(''); + handleUserRegistration(); + }; + const handleMessage = (message: SocketEvent) => { switch (message.type) { + case MessageType.ERROR_NEEDS_REGISTRATION: + resetAndReAuth(); + break; case MessageType.CONNECTED_USER_INFO: handleConnectedClientInfoMessage(message as ConnectedClientInfoEvent, setChatDisplayName); break;