1
0
mirror of https://github.com/bitwarden/browser.git synced 2025-01-04 18:37:45 +01:00

[PM-9618] Show toast when AuthUrl is null (#10108)

* Added toast message if AuthUrl is null

* added toast to desktop and browser

* fixed tests
This commit is contained in:
Ike 2024-07-15 09:04:15 -07:00 committed by GitHub
parent e7b50e790a
commit d2685e1bc5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 51 additions and 2 deletions

View File

@ -3045,6 +3045,9 @@
} }
} }
}, },
"duoHealthCheckResultsInNullAuthUrlError": {
"message": "Error connecting with the Duo service. Use a different two-step login method or contact Duo for assistance."
},
"launchDuoAndFollowStepsToFinishLoggingIn": { "launchDuoAndFollowStepsToFinishLoggingIn": {
"message": "Launch Duo and follow the steps to finish logging in." "message": "Launch Duo and follow the steps to finish logging in."
}, },

View File

@ -25,7 +25,7 @@ import { MessagingService } from "@bitwarden/common/platform/abstractions/messag
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service"; import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
import { StateService } from "@bitwarden/common/platform/abstractions/state.service"; import { StateService } from "@bitwarden/common/platform/abstractions/state.service";
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction"; import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
import { DialogService } from "@bitwarden/components"; import { DialogService, ToastService } from "@bitwarden/components";
import { BrowserApi } from "../../platform/browser/browser-api"; import { BrowserApi } from "../../platform/browser/browser-api";
import { ZonedMessageListenerService } from "../../platform/browser/zoned-message-listener.service"; import { ZonedMessageListenerService } from "../../platform/browser/zoned-message-listener.service";
@ -62,6 +62,7 @@ export class TwoFactorComponent extends BaseTwoFactorComponent {
private dialogService: DialogService, private dialogService: DialogService,
masterPasswordService: InternalMasterPasswordServiceAbstraction, masterPasswordService: InternalMasterPasswordServiceAbstraction,
accountService: AccountService, accountService: AccountService,
toastService: ToastService,
@Inject(WINDOW) protected win: Window, @Inject(WINDOW) protected win: Window,
private browserMessagingApi: ZonedMessageListenerService, private browserMessagingApi: ZonedMessageListenerService,
) { ) {
@ -84,6 +85,7 @@ export class TwoFactorComponent extends BaseTwoFactorComponent {
configService, configService,
masterPasswordService, masterPasswordService,
accountService, accountService,
toastService,
); );
super.onSuccessfulLogin = async () => { super.onSuccessfulLogin = async () => {
// FIXME: Verify that this floating promise is intentional. If it is, add an explanatory comment and ensure there is proper error handling. // FIXME: Verify that this floating promise is intentional. If it is, add an explanatory comment and ensure there is proper error handling.
@ -226,6 +228,15 @@ export class TwoFactorComponent extends BaseTwoFactorComponent {
} }
override async launchDuoFrameless() { override async launchDuoFrameless() {
if (this.duoFramelessUrl === null) {
this.toastService.showToast({
variant: "error",
title: null,
message: this.i18nService.t("duoHealthCheckResultsInNullAuthUrlError"),
});
return;
}
const duoHandOffMessage = { const duoHandOffMessage = {
title: this.i18nService.t("youSuccessfullyLoggedIn"), title: this.i18nService.t("youSuccessfullyLoggedIn"),
message: this.i18nService.t("youMayCloseThisWindow"), message: this.i18nService.t("youMayCloseThisWindow"),

View File

@ -25,6 +25,7 @@ import { LogService } from "@bitwarden/common/platform/abstractions/log.service"
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service"; import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
import { StateService } from "@bitwarden/common/platform/abstractions/state.service"; import { StateService } from "@bitwarden/common/platform/abstractions/state.service";
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction"; import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
import { ToastService } from "@bitwarden/components";
import { TwoFactorOptionsComponent } from "./two-factor-options.component"; import { TwoFactorOptionsComponent } from "./two-factor-options.component";
@ -64,6 +65,7 @@ export class TwoFactorComponent extends BaseTwoFactorComponent {
configService: ConfigService, configService: ConfigService,
masterPasswordService: InternalMasterPasswordServiceAbstraction, masterPasswordService: InternalMasterPasswordServiceAbstraction,
accountService: AccountService, accountService: AccountService,
toastService: ToastService,
@Inject(WINDOW) protected win: Window, @Inject(WINDOW) protected win: Window,
) { ) {
super( super(
@ -85,6 +87,7 @@ export class TwoFactorComponent extends BaseTwoFactorComponent {
configService, configService,
masterPasswordService, masterPasswordService,
accountService, accountService,
toastService,
); );
super.onSuccessfulLogin = async () => { super.onSuccessfulLogin = async () => {
// FIXME: Verify that this floating promise is intentional. If it is, add an explanatory comment and ensure there is proper error handling. // FIXME: Verify that this floating promise is intentional. If it is, add an explanatory comment and ensure there is proper error handling.
@ -149,6 +152,15 @@ export class TwoFactorComponent extends BaseTwoFactorComponent {
} }
override async launchDuoFrameless() { override async launchDuoFrameless() {
if (this.duoFramelessUrl === null) {
this.toastService.showToast({
variant: "error",
title: null,
message: this.i18nService.t("duoHealthCheckResultsInNullAuthUrlError"),
});
return;
}
const duoHandOffMessage = { const duoHandOffMessage = {
title: this.i18nService.t("youSuccessfullyLoggedIn"), title: this.i18nService.t("youSuccessfullyLoggedIn"),
message: this.i18nService.t("youMayCloseThisWindow"), message: this.i18nService.t("youMayCloseThisWindow"),

View File

@ -2778,6 +2778,9 @@
} }
} }
}, },
"duoHealthCheckResultsInNullAuthUrlError": {
"message": "Error connecting with the Duo service. Use a different two-step login method or contact Duo for assistance."
},
"launchDuoAndFollowStepsToFinishLoggingIn": { "launchDuoAndFollowStepsToFinishLoggingIn": {
"message": "Launch Duo and follow the steps to finish logging in." "message": "Launch Duo and follow the steps to finish logging in."
}, },

View File

@ -23,7 +23,7 @@ import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.servic
import { LogService } from "@bitwarden/common/platform/abstractions/log.service"; import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service"; import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
import { StateService } from "@bitwarden/common/platform/abstractions/state.service"; import { StateService } from "@bitwarden/common/platform/abstractions/state.service";
import { DialogService } from "@bitwarden/components"; import { DialogService, ToastService } from "@bitwarden/components";
import { import {
TwoFactorOptionsDialogResult, TwoFactorOptionsDialogResult,
@ -69,6 +69,7 @@ export class TwoFactorComponent extends BaseTwoFactorComponent implements OnDest
configService: ConfigService, configService: ConfigService,
masterPasswordService: InternalMasterPasswordServiceAbstraction, masterPasswordService: InternalMasterPasswordServiceAbstraction,
accountService: AccountService, accountService: AccountService,
toastService: ToastService,
private formBuilder: FormBuilder, private formBuilder: FormBuilder,
@Inject(WINDOW) protected win: Window, @Inject(WINDOW) protected win: Window,
) { ) {
@ -91,6 +92,7 @@ export class TwoFactorComponent extends BaseTwoFactorComponent implements OnDest
configService, configService,
masterPasswordService, masterPasswordService,
accountService, accountService,
toastService,
); );
this.onSuccessfulLoginNavigate = this.goAfterLogIn; this.onSuccessfulLoginNavigate = this.goAfterLogIn;
} }

View File

@ -6210,6 +6210,9 @@
} }
} }
}, },
"duoHealthCheckResultsInNullAuthUrlError": {
"message": "Error connecting with the Duo service. Use a different two-step login method or contact Duo for assistance."
},
"launchDuoAndFollowStepsToFinishLoggingIn": { "launchDuoAndFollowStepsToFinishLoggingIn": {
"message": "Launch Duo and follow the steps to finish logging in." "message": "Launch Duo and follow the steps to finish logging in."
}, },

View File

@ -32,6 +32,7 @@ import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/pl
import { StateService } from "@bitwarden/common/platform/abstractions/state.service"; import { StateService } from "@bitwarden/common/platform/abstractions/state.service";
import { FakeAccountService, mockAccountServiceWith } from "@bitwarden/common/spec"; import { FakeAccountService, mockAccountServiceWith } from "@bitwarden/common/spec";
import { UserId } from "@bitwarden/common/types/guid"; import { UserId } from "@bitwarden/common/types/guid";
import { ToastService } from "@bitwarden/components";
import { TwoFactorComponent } from "./two-factor.component"; import { TwoFactorComponent } from "./two-factor.component";
@ -71,6 +72,7 @@ describe("TwoFactorComponent", () => {
let mockConfigService: MockProxy<ConfigService>; let mockConfigService: MockProxy<ConfigService>;
let mockMasterPasswordService: FakeMasterPasswordService; let mockMasterPasswordService: FakeMasterPasswordService;
let mockAccountService: FakeAccountService; let mockAccountService: FakeAccountService;
let mockToastService: MockProxy<ToastService>;
let mockUserDecryptionOpts: { let mockUserDecryptionOpts: {
noMasterPassword: UserDecryptionOptions; noMasterPassword: UserDecryptionOptions;
@ -102,6 +104,7 @@ describe("TwoFactorComponent", () => {
mockSsoLoginService = mock<SsoLoginServiceAbstraction>(); mockSsoLoginService = mock<SsoLoginServiceAbstraction>();
mockConfigService = mock<ConfigService>(); mockConfigService = mock<ConfigService>();
mockAccountService = mockAccountServiceWith(userId); mockAccountService = mockAccountServiceWith(userId);
mockToastService = mock<ToastService>();
mockMasterPasswordService = new FakeMasterPasswordService(); mockMasterPasswordService = new FakeMasterPasswordService();
mockUserDecryptionOpts = { mockUserDecryptionOpts = {
@ -182,6 +185,7 @@ describe("TwoFactorComponent", () => {
{ provide: ConfigService, useValue: mockConfigService }, { provide: ConfigService, useValue: mockConfigService },
{ provide: InternalMasterPasswordServiceAbstraction, useValue: mockMasterPasswordService }, { provide: InternalMasterPasswordServiceAbstraction, useValue: mockMasterPasswordService },
{ provide: AccountService, useValue: mockAccountService }, { provide: AccountService, useValue: mockAccountService },
{ provide: ToastService, useValue: mockToastService },
], ],
}); });

View File

@ -32,6 +32,7 @@ import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.servic
import { LogService } from "@bitwarden/common/platform/abstractions/log.service"; import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service"; import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
import { StateService } from "@bitwarden/common/platform/abstractions/state.service"; import { StateService } from "@bitwarden/common/platform/abstractions/state.service";
import { ToastService } from "@bitwarden/components";
import { CaptchaProtectedComponent } from "./captcha-protected.component"; import { CaptchaProtectedComponent } from "./captcha-protected.component";
@ -94,6 +95,7 @@ export class TwoFactorComponent extends CaptchaProtectedComponent implements OnI
protected configService: ConfigService, protected configService: ConfigService,
protected masterPasswordService: InternalMasterPasswordServiceAbstraction, protected masterPasswordService: InternalMasterPasswordServiceAbstraction,
protected accountService: AccountService, protected accountService: AccountService,
protected toastService: ToastService,
) { ) {
super(environmentService, i18nService, platformUtilsService); super(environmentService, i18nService, platformUtilsService);
this.webAuthnSupported = this.platformUtilsService.supportsWebAuthn(win); this.webAuthnSupported = this.platformUtilsService.supportsWebAuthn(win);
@ -474,6 +476,15 @@ export class TwoFactorComponent extends CaptchaProtectedComponent implements OnI
} }
async launchDuoFrameless() { async launchDuoFrameless() {
if (this.duoFramelessUrl === null) {
this.toastService.showToast({
variant: "error",
title: null,
message: this.i18nService.t("duoHealthCheckResultsInNullAuthUrlError"),
});
return;
}
this.platformUtilsService.launchUri(this.duoFramelessUrl); this.platformUtilsService.launchUri(this.duoFramelessUrl);
} }
} }