Skip to content

Commit

Permalink
AXON-130: refactor login action message flow to include better error …
Browse files Browse the repository at this point in the history
…handling and analytic posting
  • Loading branch information
cabella-dot committed Feb 15, 2025
1 parent 9fe90a5 commit 5c16271
Showing 1 changed file with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,23 +95,23 @@ export class OnboardingWebviewController implements WebviewController<SectionCha
}
case OnboardingActionType.Login: {
let isCloud = true;
if (isBasicAuthInfo(msg.authInfo)) {
isCloud = false;
try {
this._analytics.fireAuthenticateButtonEvent(id, msg.siteInfo, isCloud);
try {
if (isBasicAuthInfo(msg.authInfo)) {
isCloud = false;
await this._api.authenticateServer(msg.siteInfo, msg.authInfo);
} catch (e) {
const err = new Error(`Authentication error: ${e}`);
this._logger.error(err);
this.postMessage({
type: CommonMessageType.Error,
reason: formatError(e, 'Authentication error'),
});
} else {
await this._api.authenticateCloud(msg.siteInfo, this._onboardingUrl);
}
} else {
await this._api.authenticateCloud(msg.siteInfo, this._onboardingUrl);
this.postMessage({ type: OnboardingMessageType.LoginResponse });
} catch (e) {
const env = isCloud ? 'cloud' : 'server';
this._logger.error(new Error(`${env} onboarding authentication error: ${e}`));
this.postMessage({
type: CommonMessageType.Error,
reason: formatError(e, `${env} onboarding authentication error`),
});
}
this.postMessage({ type: OnboardingMessageType.LoginResponse });
this._analytics.fireAuthenticateButtonEvent(id, msg.siteInfo, isCloud);
break;
}
case OnboardingActionType.SaveSettings: {
Expand Down

0 comments on commit 5c16271

Please sign in to comment.