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

Adding ctx.state.user support #58

Merged
merged 1 commit into from Jul 13, 2016
Merged

Adding ctx.state.user support #58

merged 1 commit into from Jul 13, 2016

Conversation

gingerich
Copy link
Contributor

@gingerich gingerich commented Jul 12, 2016

Addresses #57

  • Expose the authenticated user via ctx.state.user.
  • Add deprecation warning when accessing ctx.req.user
  • Updated unit tests

This conforms to Koa v2 best practices for passing data through the middleware stack, https://github.com/koajs/koa/blob/v2.x/docs/api/context.md#ctxstate

Note: npm install to grab new dependency

@rkusa
Copy link
Owner

rkusa commented Jul 13, 2016

Well done, thank you very much!

@rkusa rkusa merged commit 2e59974 into rkusa:v2.x Jul 13, 2016
@rkusa
Copy link
Owner

rkusa commented Aug 28, 2016

FYI: I've updated koa-passport to save the user only in one single place, which is ctx.state.user. Passport strategies are still able to access it through req.user, but users aren't. Since, because of other changes, I am planing to bump the major version (to 3.0.0) anyway, I think I'll not add a deprecation warning. But this is open for discussion.

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

Successfully merging this pull request may close these issues.

None yet

2 participants