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

How to get user id in hooks? #322

Closed
evgenyboxer opened this Issue Oct 22, 2016 · 3 comments

Comments

Projects
None yet
3 participants
@evgenyboxer
Copy link

evgenyboxer commented Oct 22, 2016

Hey,

I was wondering, how do I get the user id? I do get the token which I can decode, but shouldn't the user id be also assigned to it?

@marshallswain

This comment has been minimized.

Copy link
Member

marshallswain commented Oct 22, 2016

Currently the userId is stored as id or _id inside the token payload, so once you verify the token you can grab it from the payload.

@daffl

This comment has been minimized.

Copy link
Member

daffl commented Oct 22, 2016

In the current version if you add the populateUser hook, the user will be in params.user.

@evgenyboxer

This comment has been minimized.

Copy link
Author

evgenyboxer commented Oct 23, 2016

Thanks! It worked 👍

I used:

  create: [
    auth.verifyToken(),
    auth.populateUser(),
    addUserId(),
  ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.