teamEightTO / polito-se2-23-08

Repository for the 01SQNOV - Software Engineering II course - Thesis Management project
GNU General Public License v3.0
0 stars 1 forks source link

localStorage doesn't save logged-user data #8

Closed lorenzobn closed 12 months ago

lorenzobn commented 12 months ago

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.

TheGreatDaniad commented 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)