E
E
Egor Astreiko2019-08-21 18:42:41
Express.js
Egor Astreiko, 2019-08-21 18:42:41

How to identify the browser on the server?

Hello everyone, I want to implement a mini two-step authorization (react is used on the client, express on the server).
The idea is this:
There are two browsers ("browser 1" and "browser 2").
When authorizing through "browser 1", mail and password are sent to the server, upon successful authorization, two access and refresh tokens are created for the user, they are written to the database table:

Table structure

  • id пользователя
  • client (рандомная строка)
  • access token
  • время смерти access token
  • refresh token
  • Булевое значение находиться ли access токен в черном списке


The access token and its lifetime are returned to the user in the response body, as well as refresh token and client are returned in http only cookies.
When authorizing the same user through "browser 2", it is checked whether the token issued to this user is in the database, if so, then he receives a code in "browser 1", which he must enter in "browser 2", if the code matches, a new token is created for the user, for "browser 2".
Problem: The
user logged in, received cookies, clears all cookies related to my site, he will be redirected to the authorization page (because if there is neither an access token nor a refresh token, then he is not authorized and I will not be able to pull his data from the server).
So, redirected him to the authorization page, he enters his data again, the server checks whether there is a token that was issued to the user, it is in the database, since the user deleted the cookies on the client side, and not on the server side, and if there is a token, so he needs to enter a code, which, according to the idea, should be sent to an authorized account. But in fact, he cannot find out the code, since the client does not have any of his information issued by the server.
Question:
How can I identify the browser on the server, so that even if the user specifically deletes all cookies, I could recognize this user on the server?
Thanks in advance.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question