Refactor login logic out of GUI class.