Pass Session with Node.JS

Asked

Viewed 177 times

1

Hi, I’m having a hard time with Session in an application with nodejs and angular 4.

I’m doing it this way:

By entering the email and password on the login screen and giving Ubmit in the login form, creates an http request, which is like an ajax, it passes the fields by POST method. Node takes this request, uses the login fuction of the Mongoose that is in the user controller, if the login is valid it inserts a Boolean saying that this Session exists (call of exist), id, name and last name in the request.

Then it returns this variable to "ajax", then the angular saves this variable in the service, then checks with Boolean exist to see if Session exists, if yes it sends to bashboard.

In Dashboard is made a getSession, which is nothing more than picking up the attribute Session that was saved in login.

Until then everything right, the name of the person appears, because on the Dashboard screen it says "Hello, nameDaPessoa", but when I give F5 to update the page add the name of the person, I’m having difficulty identifying why add the name of the person, It may be some problem in Mongo or Session?

  • 2

    At a glance here.

  • I edited my question.

  • F5 reloads everything from 0 unless you submit a login token and check whether it is expired or not and return the user data. Or think of another method, such as localStorage or sessionStorage, or alternative.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.