Fix login/logout behavior