This repository was archived by the owner on Aug 13, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 33
This repository was archived by the owner on Aug 13, 2021. It is now read-only.
server error 500 req.isAuthenticated is not a function #75
Copy link
Copy link
Open
Description
Hello, I'm using passport to do authorization, i'm getting below error while using $sailsSocket
is there anyway to authorize $sailsSocket requests?
thanks!
Error from console:
error: Sending 500 ("Server Error") response:
TypeError: req.isAuthenticated is not a function
at module.exports (\api\policies\sessionAuth.js:1
4:11)
at routeTargetFnWrapper (\node_modules\sails\lib\
router\bind.js:179:5)
at \node_modules\sails\lib\router\bind.js:244:14
at callbacks (\node_modules\sails\node_modules\ex
press\lib\router\index.js:164:37)
at param (\node_modules\sails\node_modules\expres
s\lib\router\index.js:138:11)
at param (\node_modules\sails\node_modules\expres
s\lib\router\index.js:135:11)
at pass (\node_modules\sails\node_modules\express
\lib\router\index.js:145:5)
at nextRoute (\node_modules\sails\node_modules\ex
press\lib\router\index.js:100:7)
at callbacks (\node_modules\sails\node_modules\ex
press\lib\router\index.js:167:11)
at \node_modules\sails\lib\router\bind.js:187:7
at module.exports (\node_modules\sails\lib\hooks\
cors\clear-headers.js:14:3)
at routeTargetFnWrapper (\node_modules\sails\lib\
router\bind.js:179:5)
at callbacks (\node_modules\sails\node_modules\ex
press\lib\router\index.js:164:37)
at param (\node_modules\sails\node_modules\expres
s\lib\router\index.js:138:11)
at pass (\node_modules\sails\node_modules\express
\lib\router\index.js:145:5)
at nextRoute (\node_modules\sails\node_modules\ex
press\lib\router\index.js:100:7) [TypeError: req.isAuthenticated is not a functi
on]policies\sessionAuth.js
module.exports = function(req, res, next) {
// User is allowed, proceed to the next policy,
// or if this is the last policy, the controller
if (req.isAuthenticated()) {
return next();
}
// User is not allowed
// (default res.forbidden() behavior can be overridden in `config/403.js`)
//return res.forbidden('You are not permitted to perform this action.');
return res.redirect('/auth/signin/');
};config\policies.js
module.exports.policies = {
/***************************************************************************
* *
* Default policy for all controllers and actions (`true` allows public *
* access) *
* *
***************************************************************************/
'*': 'sessionAuth',
'auth': {
'*': true
}
/***************************************************************************
* *
* Here's an example of mapping some policies to run before a controller *
* and its actions *
* *
***************************************************************************/
// RabbitController: {
// Apply the `false` policy as the default for all of RabbitController's actions
// (`false` prevents all access, which ensures that nothing bad happens to our rabbits)
// '*': false,
// For the action `nurture`, apply the 'isRabbitMother' policy
// (this overrides `false` above)
// nurture : 'isRabbitMother',
// Apply the `isNiceToAnimals` AND `hasRabbitFood` policies
// before letting any users feed our rabbits
// feed : ['isNiceToAnimals', 'hasRabbitFood']
// }
};Metadata
Metadata
Assignees
Labels
No labels