More login work


Prevent linking to wrong page for logouts
* #410, #1625, #1498