Node.js 与connect mongo、passport和;passport本地猫鼬,会话未持续
试图保存会话并具有req.isAuthenticated()、req.user等功能,但无法使其正常工作 会话不是持久的,只是由于某种原因不能正常工作 应用程序ts 路由。ts 控制器.tsNode.js 与connect mongo、passport和;passport本地猫鼬,会话未持续,node.js,typescript,express,mongoose,passport.js,Node.js,Typescript,Express,Mongoose,Passport.js,试图保存会话并具有req.isAuthenticated()、req.user等功能,但无法使其正常工作 会话不是持久的,只是由于某种原因不能正常工作 应用程序ts 路由。ts 控制器.ts 如果有任何帮助,我将不胜感激。发现我需要调用passport.authenticate作为路由的中间件,并且必须进行路由链接才能正常工作 app.route('/authenticate') .post(passport.authenticate('local'))
如果有任何帮助,我将不胜感激。发现我需要调用passport.authenticate作为路由的中间件,并且必须进行路由链接才能正常工作
app.route('/authenticate')
.post(passport.authenticate('local'))
.post((req: Request, res: Response, next: NextFunction) => {
try {
console.log(chalk.cyanBright('Request from: ') + chalk.yellowBright(req.originalUrl));
console.log(chalk.cyanBright('Request type: ') + chalk.yellowBright(req.method));
next();
} catch (error) {
console.error(chalk.redBright(error));
}
}, this.authenticationController.authenticate);
Some Code
Some Code
app.route('/authenticate')
.post(passport.authenticate('local'))
.post((req: Request, res: Response, next: NextFunction) => {
try {
console.log(chalk.cyanBright('Request from: ') + chalk.yellowBright(req.originalUrl));
console.log(chalk.cyanBright('Request type: ') + chalk.yellowBright(req.method));
next();
} catch (error) {
console.error(chalk.redBright(error));
}
}, this.authenticationController.authenticate);