fix(addin-host): treat API key alone as configured (don't require username)

After the previous fix made Username optional in the Settings dialog and
the credential store, TryInitializeCrm still bailed out when Username
was blank — leaving the add-in in "not configured" state even though
the user had saved a valid API key.

Only ApiKey is required now. The check matches the new contract used by
EspoCrmClient (X-Api-Key alone is sufficient for API-User credentials).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
PointStar
2026-05-11 16:31:47 +03:00
parent b6e4e38833
commit 484e908026
+2 -2
View File
@@ -284,9 +284,9 @@ namespace OutlookAddin.Services
DisposeCrmStack();
var creds = CredentialStore.Load();
if (creds == null || string.IsNullOrWhiteSpace(creds.Username) || string.IsNullOrWhiteSpace(creds.ApiKey))
if (creds == null || string.IsNullOrWhiteSpace(creds.ApiKey))
{
Logger.Information("AddInHost: no stored credentials — CRM features disabled until first-run setup");
Logger.Information("AddInHost: no stored API key — CRM features disabled until first-run setup");
CrmClientChanged?.Invoke(this, EventArgs.Empty);
return;
}