0

Support re-authing on invalid access token

This commit is contained in:
Gabe Kangas 2022-05-25 22:51:17 -07:00
parent 09ea1951be
commit 281829a473
No known key found for this signature in database
GPG Key ID: 9A56337728BC81EA

View File

@ -175,15 +175,24 @@ export function ClientConfigStore() {
setAccessToken(newAccessToken); setAccessToken(newAccessToken);
setLocalStorage(ACCESS_TOKEN_KEY, newAccessToken); setLocalStorage(ACCESS_TOKEN_KEY, newAccessToken);
setChatDisplayName(newDisplayName); setChatDisplayName(newDisplayName);
// sendEvent(AppStateEvent.Registered);
} catch (e) { } catch (e) {
sendEvent(AppStateEvent.Fail); sendEvent(AppStateEvent.Fail);
console.error(`ChatService -> registerUser() ERROR: \n${e}`); console.error(`ChatService -> registerUser() ERROR: \n${e}`);
} }
}; };
const resetAndReAuth = () => {
console.log('!!!!! reauth!!');
setLocalStorage(ACCESS_TOKEN_KEY, '');
setAccessToken('');
handleUserRegistration();
};
const handleMessage = (message: SocketEvent) => { const handleMessage = (message: SocketEvent) => {
switch (message.type) { switch (message.type) {
case MessageType.ERROR_NEEDS_REGISTRATION:
resetAndReAuth();
break;
case MessageType.CONNECTED_USER_INFO: case MessageType.CONNECTED_USER_INFO:
handleConnectedClientInfoMessage(message as ConnectedClientInfoEvent, setChatDisplayName); handleConnectedClientInfoMessage(message as ConnectedClientInfoEvent, setChatDisplayName);
break; break;