Support re-authing on invalid access token
This commit is contained in:
parent
09ea1951be
commit
281829a473
@ -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;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user