Refactor the login control.