我在节点后端使用express/express-session/passport,这是我的注销码。我的网络客户端正常注销,但移动客户端没有登录
// GET /logout
exports.logout = (req, res) => {
req.logout();
if (req.body.type === "mobile") {
return res.status(200).json({success: true});
}
res.redirect('/');
};
此网页应用程序在http://myapp.dev:3000
上运行。只要我在Web应用程序上并单击注销按钮,我就可以登录/注销,而不会出现任何问题。
我也有一个运行在192.168.2.30:8100
上的Ionic(移动应用程序)。当我点击我的移动应用程序中的注销按钮时,我会像往常一样向/注销请求。
$stateProvider.state("auth.signout", {
url: "/signout",
controller: "SignoutController",
resolve: {
redirect: function($http, $state, Config) {
$http.get(`${Config.url("/logout")}`, {
type: "mobile"
}, {
withCredentials: true
}).then(res => {
$state.go('auth.signin');
}).catch(res => {
console.log(res);
alert("Could not log out");
});
}
}
});
当我点击我的移动客户端上的退出按钮,我得到的JSON回来,但我无法从我的移动客户端删除Cookie,因此不断重新连接。
任何想法如何防止这种情况?
您尝试删除您的cookie以及尝试删除它时出现了哪些错误? – VtoCorleone
@VtoCorleone我该怎么做?它应该是后端的责任,告诉webview删除cookies,我相信'req.logout()'设置必要的标题。除了输入'myapp.dev/logout'外,我的web应用程序没有代码,并且工作正常。 – Aris