No access to context in Strategy.
See original GitHub issueHello. When I try to get user data in strategy, I can’t get the state data. For example, I need to authenticate user to tether his data of different socials, so in express I’ld need  to set passReqToCallback: true in strategy.
For now I made a hack in my project- in file lib/framework/request.js I changed exports.create function to this:
  const req = Object.create(ctx.request, properties)
  // add passport http.IncomingMessage extensions
  req.login = IncomingMessageExt.logIn
  req.logIn = IncomingMessageExt.logIn
  req.logout = IncomingMessageExt.logOut
  req.logOut = IncomingMessageExt.logOut
  req.isAuthenticated = IncomingMessageExt.isAuthenticated
  req.isUnauthenticated = IncomingMessageExt.isUnauthenticated
  req.ctx = ctx;
  return req
}
Just added req.ctx=ctx; before return req so I can use ctx in my strategy.
Issue Analytics
- State:
 - Created 7 years ago
 - Reactions:5
 - Comments:17 (7 by maintainers)
 
Top Results From Across the Web
How Leaders Create the Context for Strategy Execution
This requires, first of all, that everyone has a reasonably shared understanding of the overall strategy; and second, that everyone makes it ...
Read more >Don't Try to Communicate Strategy Without Context - Gartner
Communications leaders expect managers to spread the word on strategy; make sure they have and share the context employees need.
Read more >In the strategy pattern can the strategy take the Context as ...
One issue I see with your approach is that there would a tight coupling between the concrete Context class and the instances of...
Read more >Putting Context Into Strategy Development - L.E.K. Consulting
Strategy is all about choices — coherent choices that fit into an overarching plan to reach an objective. We often use the diagram...
Read more >Strategy - UNC Computer Science
Context checks to see if it has a Strategy object before accessing it. If there is one, then Context uses it normally. If...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@leebenson Just published (it is a major release because of the passport update to
0.4.x)I pass the database connection through middlewares via
ctx.stateso having access to that in the strategy would be nice, for persistence.