Closed gibson closed 6 years ago
Hi @gibson,
because on the state from F.onAuthorize
depends next processing of the request. I think that you use a global middleware, but update it in some definition file to:
F.use('session', '*', ['web']);
And the middleware with session will be executeda after F.onAuthorize
. Global middleware is executed before is the request processed.
That's explation 💯
i need execute session
module before F.onAuthorize
Aha ... Then you need to use a global middleware and you can do it like this:
F.use('session');
BTW: this global middleware is for all requests, so update your middleware like that:
F.middleware('session', function(req, res, next) {
if (req.isStaticFile)
return next();
// ... your code
// ... your code
// ... your code
// ... your code
});
Or you can call session
in F.onAuthorize
directly:
F.onAuthorize = function(req, res, flags, next) {
YOURSESSION(req, res, function(session) {
// your logic for authorization
});
};
thx, its working
Why F.onAuthorize run before session module initialize? I have in session data from passport.js and i want use this data for set auth status, but cant - in F.onAuthorize req doesnt have session property