Fix logic for login logout