Extracting login code to a Angular service.