memaar92 / transcendence

MIT License
3 stars 0 forks source link

I get logged out after access token expires and I haven't been active for the access token lifetime + chat window "freezes" due to unauthorized access #77

Open memaar92 opened 1 week ago

memaar92 commented 1 week ago

Observation 1: Log in. Stay on the main_menu page and do nothing till access token expires. Then click something (e.g. on the profile). You get back to sign-up (and you are logged out). Expectation: Access token gets automatically refreshed in the background. Most likely this is also somehow related to being "randomly "kicked out while in the chat or when starting a game.

This problem seems to be caused by the refresh token endpoint being called twice. In the first call it returns 200. In the second call it returns an error since the first call blacklisted the refresh token that the second call uses.

In between there is a call to checkToken() by the chatHandler. If this call gets removed, the refresh token is only called once and the the behavior is as exepcted (new issuance of access token).

Need to investigate why checkToken() was actually a problem and what the consequences of removing it are.

Observation 2: Chat with another user. Stay in the chat windown and don't do anything till access token expires. Then close the chat window. In the general Chat UI you know only see the tabs 'Chat' and 'Friends'. No active users are shown and no chats. They only get shown once you refresh the page.

Observation 3: Open the chat UI. Don't do anything until the access token expires. Then open that chat window to chat with another user. There are no messages shown (even if messages have been sent) and you cannot close the window or send any messages. Unless you refresh the page.

--> console log: Initializing chat with params: {recipient: 'sugarythrushe9460543'} chatHandler.js:25 Closing existing WebSocket connection chatHandler.js:29 Creating new WebSocket connection chatHandler.js:106 WebSocket connection closed: 1000 chatHandler.js:30 WebSocket connection to 'wss://localhost/ws/live_chat/%7D' failed: init @ chatHandler.js:30 updateChat @ live-chat.js:13 handlePostUpdate @ router.js:136 updateView @ router.js:195 chatHandler.js:106 WebSocket connection closed: 1006 api.js:47 GET https://localhost/api/token/check/ 401 (Unauthorized) get @ api.js:47 checkToken @ chatHandler.js:86 onClose @ chatHandler.js:110 ws.onclose @ chatHandler.js:45