2

I am making an live - chat platform, but I cannot find a way to verify a users identity.

I do not have any code because there arent any errors.

2 Answers2

0

You need a way to uniquely identify the socket to each client, so you'd have to do something like this:

Login request to API > API retrieves user from database > Sends Response to Client > Create websocket connection in frontend, pass in unique id from database response through url params to wss endpoint > you can also do db transactions with this unique identifier to add more fine grained control for caching/session tracking.

It's hard to really give specific code examples if you're not sharing your code.

  • Okay, I do not need a code example. I just would like to know if there is a way to get the identifier. I need it to be secure, so a google id would not work. I would also like it to be different after logging out and back in. Thanks in advance! – Liam Sholts Sep 27 '21 at 22:04
0

I ended up solving this after reading this article. They used the express-session package and showed how to get the req.session variable from a socket.io event.

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jun 07 '22 at 01:11