Closed lorenzobn closed 12 months ago
Added a route GET /self
in the backend that returns the user data, whether teacher or student.
It is being called on every refresh in react app, if the data is collected, it means that the user is still authenticated and their data is updated.
Otherwise the user should be logged out or handled differently (not handled in the code yet)
Hi guys,
This is about the client part of the application. When the login is done, the server returns a JSON object
res.status(200).json({ id: userObj.id, type: type, token });
. The content of this response should be saved in the localStorage by the client, so that in the UI we can access all the required fields (for example the ID in the navbar for conditional rendering).If you use React Developer Tools, at the very top of the view, you can see a
Store
object which is initialized as default like in the declaration inside store.js file:this.user = { id: "", type: "professor", authenticated: false, };
.Since the user is authenticated, those data shoudld have been updated. They should not be default anymore.