S
S
Sergey2018-08-08 22:31:03
JavaScript
Sergey, 2018-08-08 22:31:03

How to work with user sessions in react?

The question is not so specific to React, but since the application is made on it, it will probably add some context
. Who can "on the fingers" explain how the process of working with user sessions works and what advantages it gives? Including front and backend
There are long user registration and authorization forms, "sensative" data like card numbers, no CVV and similar, but there is a login/password. The customer really wants to do everything in a smart and safe
way. As far as I understand, each POST / GET / .. request to the server must be accompanied by a certain key that is somehow verified on the server?
The backend documented the API that each request should have

"Header{
authtoken="",
content-type:""application/json""
}"

When the user has successfully logged in, a response from the server comes with res.data
"AuthToken": "cG11bmRvbGltb29sZUB0aGVraW5pZ3JvdXAuY29tOjYzNjY5MjkyODg2NjA1NDY0Nw==",

But there are methods during registration (when the user has not logged in yet) where this parameter is required. I do not quite understand the correct flow of this authToken and where it comes from

Answer the question

In order to leave comments, you need to log in

1 answer(s)
H
holymotion, 2018-08-08
@holymotion

You receive a token upon registration or authorization, store it in the state and local storage, pull it out when making requests to the api.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question