Handles login redirect and logout correctly now.