public async Task <IActionResult> PostUser(RegisterUserRequestModel requestModel) { if (requestModel?.DeviceInfo == null || string.IsNullOrWhiteSpace(requestModel.DeviceInfo.Handle) || InvalidPlatForm(requestModel.DeviceInfo.Platform) || string.IsNullOrWhiteSpace(requestModel.UserInfo?.UserName)) { return(BadRequest()); } var email = User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Email)?.Value; var user = await _userAuthenticationService.Add3rdPartyUser(requestModel.UserInfo.UserName, email); if (user?.User == null) { return(BadRequest("User could not be created. The username is invalid or is already be in use.")); } var update = requestModel.Registration?.RegistrationId == null ? null : await _hubRegistrationService.UpdateHubRegistration(new UpdateRegistrationRequestModel { Handle = requestModel.DeviceInfo.Handle, Platform = requestModel.DeviceInfo.Platform, RegistrationId = requestModel.Registration.RegistrationId, Username = requestModel.UserInfo.UserName }); HubRegistrationModel reg; if (update == null) { //todo: need to pass tags reg = await _hubRegistrationService.CreateHubRegistration(requestModel.DeviceInfo.Handle); } else { reg = new HubRegistrationModel { RegistrationId = update.RegistrationId }; } var clientAuthConfigModel = GetClientAuthConfigModel(); return(Ok(new StartupResponseModel { ClientAuth = clientAuthConfigModel, HubRegistration = reg, Authentication = new AuthenticationModel { Token = string.Empty }, })); }