Fixed the login redirect logic.