У меня есть код авторизации на Sails который создает новую сессию, вот код, все предельно просто, но даже самые вроде бы очевидные костыли не помогли
create: function (req, res) {
var username = req.param('username'),
password = req.param('password');
if ((!username || !password) || (username || password) == undefined) return res.redirect('/login');
User.findOneByUsername(username).exec(function (err, user) {
if (err) return res.json(err);
if (passwordHash.verify(password, user.encryptedPassword)) {
req.session.auth = true;
req.session.User = user;
res.redirect('/');
} else if (passwordHash(passwordHash.verify(password, user.encryptedPassword)) == false) {
res.redirect('/login');
}
})
},
/home/anton/project/api/responses/forbidden.js:81
else return res.view('403', locals, function viewReady(viewErr, html) {
^
TypeError: Object #<ServerResponse> has no method 'view'
at Object.forbidden (/home/anton/project/api/responses/forbidden.js:81:19)
at ServerResponse.bound [as forbidden] (/usr/lib/node_modules/sails/node_modules/lodash/dist/lodash.js:729:21)
at /usr/lib/node_modules/sails/lib/hooks/csrf/index.js:65:28
at createToken (/usr/lib/node_modules/sails/node_modules/express/node_modules/connect/lib/middleware/csrf.js:82:44)
at /usr/lib/node_modules/sails/node_modules/express/node_modules/connect/lib/middleware/csrf.js:54:7
at Object.ondone (/usr/lib/node_modules/sails/node_modules/express/node_modules/connect/node_modules/uid2/index.js:40:8)