Answer the question
In order to leave comments, you need to log in
How to make a full Flask + React login?
I have a form where you can log in a user, and if the data exists in the database, then the session key will be returned in response
. And then the very essence of the question appears, what should I do with it? How to use a session key so that a user can log into the network and write on his own behalf and edit only his profile?
There is some material for understanding how to implement a full-fledged login
Answer the question
In order to leave comments, you need to log in
1. Upon successful authorization, send a token to the client.
2. Store the token in a cookie. Check for its presence during initialization and either render the variant for the logged in user after downloading his data, or for the guest.
3. Having data such as user id, you can easily distinguish whether you should show the edit button in your profile or not:
const { me, user } = this.props;
const isOwner = me.id === user.id;
return (
<>
{isOwner && <Button onClick={this.handleEditClick}>Edit</Button>}
{/* other jsx */}
</>
);
Upon successful authorization, generate and return a jwt-token from the server in which the user data and access rights will be embedded. Based on this information, already at the front, determine what needs to be rendered and what not. For each request to the server, pass this jwt token in the header, and validate it there. If valid, then see the rights sewn into it.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question