Refactor the login.