Move common login functionality out to common helper class.