我爲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