22 public static JsonWebToken
EnsureSuccess(
this IOperationResult<ILoginResult> loginResult, ILogger logger)
24 ArgumentNullException.ThrowIfNull(loginResult);
28 loginResult.EnsureNoErrors();
30 catch (GraphQLClientException ex)
35 var data = loginResult.Data!.Login;
36 var errors = data.Errors;
39 foreach (var error
in errors)
41 if (error is ILogin_Login_Errors_ErrorMessageError errorMessageError)
43 "Authentication error ({code}): {message}{additionalData}",
44 errorMessageError.ErrorCode?.ToString() ??
"No Code",
45 errorMessageError.Message,
46 errorMessageError.AdditionalData !=
null
47 ? $
"{Environment.NewLine}{errorMessageError.AdditionalData}"
51 "Unknown authentication error: {error}",
56 if (data.LoginResult ==
null)
60 var errorMessage = errors.OfType<ILogin_Login_Errors_ErrorMessageError>().FirstOrDefault();
61 if (errorMessage !=
null)
64 throw new AuthenticationException($
"Null bearer field and {errors.Count} non-ErrorMessage errors:{(errors.Count > 0 ? $"{Environment.NewLine}\t- {String.Join($
"{Environment.NewLine}\t- ", errors)}
" : String.Empty)}");