Moved login functionality to a login service.