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.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
james2406
changed the title
Ability to access data on the session within a passport strategy
Ability to access the session data within a passport strategy
Mar 4, 2021
This change needs to be made in the passport-adapter.ts file. We'll need to run global middleware at start of function instead of the end, we can access ctx.
So something like this:
+ // First run global middleware so we can access session+ const globalMiddleware = getAllMiddlewareForModule({} as any)+ await handleRequestWithMiddleware(req, res, globalMiddleware)+ // pseudo code: if passportAuth config is callback, call it with `res.blitzCtx` as argument
// rest of passport code
- const globalMiddleware = getAllMiddlewareForModule({} as any)- await handleRequestWithMiddleware(req, res, [...globalMiddleware, ...middleware])+ // Now only run the specific passport middleware that we constructed+ await handleRequestWithMiddleware(req, res, middleware)
What do you want and why?
I would like to be able to access the session data inside the verify callback of the passport strategy.
This session data is set on an anonymous session via the
ctx.session.$setPublicData()
andctx.session.$setPrivateData()
functions.Possible implementation(s)
Potentially, the
passportAuth
function could accept a callback which would provide thectx.session
, like so:The text was updated successfully, but these errors were encountered: