Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

req.user always empty when calling /user/me #150

Open
Brainshack opened this issue May 29, 2016 · 4 comments
Open

req.user always empty when calling /user/me #150

Brainshack opened this issue May 29, 2016 · 4 comments

Comments

@Brainshack
Copy link

Hello,

I have setup a brand new sails app with sails auth. I am using the local strategy. I create a User as described in the docs and authenticated using /auth/local. The auth call returns the correct user. However, when I call /user/me afterwards, the result is empty. I am using Postman to make the calls. A Cookie with the session id exists, so I suppose there maybe needs to be something else setup? I get the same error, when I try using the socket api from the browser,

@ekzhang
Copy link

ekzhang commented Jul 5, 2016

I can confirm I am having the same problem. Did you ever figure out the issue?

It appears to me that the UserController's "me" action isn't being called for some reason, even if you route it directly. I've tried calling "sails.log.info()" in the "me" action, and nothing is being logged. I've also tried editing the response passed in to res.ok(), and that didn't change anything either.

@smyth64
Copy link

smyth64 commented Jul 23, 2016

Got the same problem =/

@smyth64
Copy link

smyth64 commented Jul 23, 2016

I found a solution!
Use this:
https://github.com/langateam/sails-permissions

Just use the files from sails-permission code!
I had problems using sails-auth only, but now everything works like charm :)

(even /user/me) ;)

@movehand
Copy link

movehand commented Oct 20, 2016

+1
In my case, deserializeUser is never called. So the user object is not attached to req.user.
Adding the passport policy for UserController in config/policies.js will invoke deserializeUser, and the user will then be attached, but I'm not sure whether if this is the right way to do it.

In config/policies.js:

UserController: {
  me: ['passport']
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants