これは私の戦略であり、server.register()で定義されています。私はチュートリアルの作業に基づいています。文字通りコピーされていますが、動作しません。request.auth.session.set(user_info)not working HapiJS
server.auth.strategy('standard', 'cookie', {
password: 'somecrazycookiesecretthatcantbeguesseswouldgohere', // cookie secret
cookie: 'app-cookie', // Cookie name
isSecure: false, // required for non-https applications
redirectTo: '/login',
ttl: 24 * 60 * 60 * 1000 // Set session to 1 day
});
server.auth.default({
strategy: 'standard',
mode: 'required',
scope: ['admin']
});
これは、エラーが発生し、私のログインルートです:
server.route({
method: 'POST',
path: '/login',
config: {
auth: false,
validate: {
payload: {
email: Joi.string().email().required(),
password: Joi.string().min(2).max(200).required()
}
},
handler: function (request, reply) {
getValidatedUser(request.payload.email, request.payload.password)
.then(function (user) {
if (user) {
//ERROR OCCURS HERE: IT SAYS SESSION IS UNDEFINED
request.auth.session.set(user);
return reply('Login Successful!');
} else {
return reply(Boom.unauthorized('Bad email or password'));
}
});
// .catch(function (err) {
// return reply(Boom.badImplementation());
// });
}
}
});
私はたくさんのことを試してみたが、この部分は、この作品のために重要であると私は同じ問題を持つ人を見つけることができません。助けてください!
は「動かない」あなたを助けるために人々のために十分な情報ではありません。何が起こった、あなたは何を期待していたのですか?エラーメッセージが表示されましたか?彼らは何を言いましたか? –
それはもう解決されません。@mcmoの答えが – Forget