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.
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.
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.
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.