相关疑难解决方法(0)

为什么Node中的PassportJS不会在注销时删除会话

我无法让我的系统注销PassportJS.似乎正在调用注销路由,但它不会删除会话.如果用户没有以特定路线登录,我希望它返回401.我调用authenticateUser来检查用户是否已登录.

非常感谢!

/******* This in index.js *********/
// setup passport for username & passport authentication
adminToolsSetup.setup(passport);

// admin tool login/logout logic
app.post("/adminTool/login",
    passport.authenticate('local', {
        successRedirect: '/adminTool/index.html',
        failureRedirect: '/',
        failureFlash: false })
);
app.get('/adminTool/logout', adminToolsSetup.authenticateUser, function(req, res){
    console.log("logging out");
    console.log(res.user);
    req.logout();
    res.redirect('/');
});


// ******* This is in adminToolSetup ********
// Setting up user authentication to be using user name and passport as authentication method,
// this function will fetch the user information from the user name, and compare the password …
Run Code Online (Sandbox Code Playgroud)

javascript logout node.js express passport.js

65
推荐指数
7
解决办法
5万
查看次数

标签 统计

express ×1

javascript ×1

logout ×1

node.js ×1

passport.js ×1