V
V
vovarevenko2017-10-28 16:30:42
Yii
vovarevenko, 2017-10-28 16:30:42

How to check authorization in Node.js?

Good day!
There is a project on Yii2. It is necessary to implement a chat with preference and profurnets.
At the moment there is a connection to the server using socket.io. After the connection, the user ID is transmitted. How to check if a user is logged in? Is it safe to transfer a token along with the user ID and compare the transferred token on the server with the user token from the database? I understand that in this case, anyone can connect to the server, knowing the token. Is it possible to use something that Yii2 stores in cookies? If so, how can this be deciphered?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
Boris Korobkov, 2017-10-28
@BorisKorobkov

When authenticating a user in PHP:
On the client in JS:
On the socket server:

  1. decrypt token,
  2. check ip, user-agent

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question