private static void SetErrorsToContext(IUserProfileFormContext <TProfile> context, BaseGigyaResponse response) { if (response.ValidationErrors != null && response.ValidationErrors.Any()) { foreach (var validationError in response.ValidationErrors) { // // TODO: find better way to map field name to profile property // switch (validationError.FieldName) { case "profile.email": context.SetError(x => x.Email, validationError.Message); break; default: context.SetGeneralError(validationError.Message); break; } } } else { context.SetGeneralError(response.UserFriendlyFailureMessage); } }
public async Task UpdateProfileAsync(IUserProfileFormContext <TProfile> context) { var setAccountResponse = await _restApiClient.SetAccountInfoAsync(context.DID, context.Profile); if (setAccountResponse.ErrorCode > 0) { _logger.LogError( $"did: {context.DID} " + $"Gigya.setAccountInfo for EXISTING user error -> {setAccountResponse.GetFailureMessage()}"); SetErrorsToContext(context, setAccountResponse); } }
public async Task CreateProfileAsync(IUserProfileFormContext <TProfile> context, string recoveryToken = null, string recoveryData = null) { var loginResponse = await _restApiClient.NotifyLogin(context.DID); if (loginResponse.ErrorCode != 0) { throw new Exception( $"Gigya.notifyLogin error -> {loginResponse.GetFailureMessage()}"); } var connection = new GigyaOwnIdConnection { PublicKey = context.PublicKey, RecoveryToken = recoveryToken, RecoveryData = recoveryData }; var setAccountMessage = await _restApiClient.SetAccountInfoAsync(context.DID, context.Profile, new AccountData(connection)); if (setAccountMessage.ErrorCode > 0) { _logger.LogError($"did: {context.DID} " + $"Gigya.setAccountInfo (profile) for NEW user error -> {setAccountMessage.GetFailureMessage()}"); var removeUserResult = await _restApiClient.DeleteAccountAsync(context.DID); if (removeUserResult.ErrorCode != 0) { throw new Exception( $"Gigya.deleteAccount with uid={context.DID} error -> {removeUserResult.GetFailureMessage()}"); } SetErrorsToContext(context, setAccountMessage); } }
public Task UpdateProfileAsync(IUserProfileFormContext <EmptyProfile> context) { return(Task.FromException(new NotSupportedException())); }
public Task CreateProfileAsync(IUserProfileFormContext <EmptyProfile> context, string recoveryToken = null, string recoveryData = null) { return(Task.FromException(new NotSupportedException())); }