memaar92 / transcendence

MIT License
3 stars 0 forks source link

chat missing info -> chat with undefined #88

Open StrongCoding opened 5 days ago

StrongCoding commented 5 days ago

when opening /live_chat/ -> waiting till access token lifetime is done -> opening a chat -> chat with undefined

76

Pommfritz0308 commented 5 days ago

error origin: trying to switch from chat home to chat room after 1006 code (Auth error) using init method the currentReceiverId is not set quick fix: refreshing the token before opening the websocket connection open for better suggestions

memaar92 commented 5 days ago

the fix you pushed is not working b/c checkToken() is called but the function is deleted. The checkToken() that is deleted would not work b/c of a missing trailing backslash in the url.

you could do something like this:

var auth = await this.checkToken(); if (!auth) { await this.refreshToken(); }

and the checkToken() function needs to make the API call with trailing backslash, like this: const response = await api.get('/token/check/');

seems to work for me well enough. And it actually makes sense to check auth before opening a websocket connection (not a quick fix in my opinion)

memaar92 commented 4 days ago

Otherwise would be interesting to know what Steve is actually doing @stevebalk . Because he also uses the middleware that checks whether auth is valid whenever a websocket connection gets opened. How does he handle the case when the middleware states that the auth is not valid because the access token is expired. Could not find any request to try to refresh the token

Pommfritz0308 commented 4 days ago

Sorry, I called the wrong function. Instead of await checkToken() I meant to call just await refreshToken() before opening the web socket. Then it works too.

memaar92 commented 4 days ago

Refreshing the token everytime no matter what seems to create issues in connection to Waynes refresh attempt in the Frontend. See my comment in the commit. Please test again