Sails.js + passport.js req.user undefined

I am using sails.js as backend / API and angular js as front end.

Server and client are in a different domain.

When I authenticate my user with a passport, I establish a sails session with a custom object.

Then when I am authenticated and I start a new request from my front to list the products, my server (sails.js) req.user is undefined and there is no user in my session that I created.

How can I solve this problem? I would like to set up the current user as a session on my server to avoid getting it every time with an ID. I will have better performance.

Any ideas?

Thank,

+3


source to share


2 answers


Ok I found the answer.

You need to add this line to angularjs app.js



$ httpProvider.defaults.withCredentials = true;

thank

+2


source


When you login / sign in return user data as API instead of using seasons.



+1


source







All Articles