fixes bug 947335 - bad message and redirect

@rhelmer r?

So now, if you're on a page like `/login/?next=/foo` it will use the `/foo` variable. Otherwise, it'll use the page you're on, except if you're already on the `/login/` page.