我为Expressjs(此时没有护照)使用Stormpath来处理我的用户注册。我非常担心注销用户的正确方法。用户注销:重定向GET到POST(节点/快递)
之前,我总是通过GET方法做到这一点,但Stormpath explicitly requires a POST call to the /logout page。
我只显示当用户通过Stormpath登录的用户菜单,这是超级简单的中间件,我在我的router.js在快递:现在
router.use(stormpath.getUser, function (req, res, next) {
if (req.user) {
req.session.useremail = req.user.email;
}
next();
});
,当然在此菜单中有注销条目。我希望我的用户点击此链接注销,但是我知道当使用类似<a href="/logout">Logout</a>
的锚链接时,会发送GET请求,而不是POST。
我一直在寻找无数的方法来重定向GET请求到POST,但我觉得这是绝对错误的方式。此外,我觉得这将毫无意义使用表单像菜单里面:
<ul>
<li>User Profile</li>
<li>User Settings</li>
<form action="/logout" method="/post">
<input type="submit">
</form>
</ul>
所以现在的问题是:什么是简单地退出通过POST的用户的最佳方法是什么?
你好!我在[Stormpath](https://stormpath.com)工作,并将更改实施到POST。此SO讨论是我们为什么选择使用POST的一个很好的总结:http://stackoverflow.com/questions/3521290/logout-get-or-post – robertjd