How Angular should get the data of the logged in user (session)

26 Views Asked by At

My and my classmate currently working in a project, where I creating the backend in Node.js with express, and he is creating the frontend in Angular.

Currently we try to make the registering (already working, also, we using mysql for the database) work, as well as the login and logout functions. I'm using passport, passport-local and express-sessions for the authentication and for the session management. But I have and issue where I have been stuck for days now, and I can't really understand that.

When the backend is creating the session and serializing/deserializing the user, from where should the Angular front get the user data? From the cookie what is created? Or I should send the user data in JSON (like se sending everything else), and when the back get a HTTP request, IT should check if there is an authenticated user and sending back the data after that?

Also, if its the first (cookie) option or another which I didn't think, please tell me what should we be using.

When should be done with these already, so every help and information would be appreciated.

Also, if you need any source code, please tell me and I will provide it.

0

There are 0 best solutions below