Answer the question
In order to leave comments, you need to log in
Authorization - where to initialize?
Good afternoon!
I don't know where it would be more correct to initialize and what logic to choose for the cookie-based session authentication service to work.
When we authenticate, we receive the corresponding cookies.
Next, we dispatch the user.
When the application loads or when the page is reloaded, the state of the application no longer knows that we are authorized.
I would probably create a cell in localStorage and write the user's data there.
When loading, if the cell is present, then temporarily we are in the state of the application will be authorized, at the same time, we will send a request to the server for user data.
The latter for two reasons.
The first is to make sure that we are really authorized.
Second - Update user data.
Question: How do they do it in general and how to implement it competently?
Add. question: What files to create, where should they be?
The last question is probably more about architecture.
How should this ideally be implemented? Although I know that there are no strict standards in the js world.
Current architecture:
src
- components
-- Something.js
- containers
-- App.js
- actions
-- someActionCreator.js
- reducers
-- someReducer.js
-- rootReducer.js
- index.js
- store.js
Answer the question
In order to leave comments, you need to log in
When the application loads or when the page is reloaded, the application state no longer knows that we are authorized.
I would probably create a cell in localStorage and write the user's data there.
When loading, if the cell is present, then temporarily we are in the state of the application will be authorized, at the same time, we will send a request to the server for user data.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question