1
0
mirror of https://github.com/bitwarden/browser.git synced 2025-01-24 21:41:33 +01:00

Add isLoginWithPasskeySupported function to reduce client type checking in template.

This commit is contained in:
Alec Rippberger 2024-10-01 13:02:39 -05:00
parent a104a9250d
commit ca0520cea0
No known key found for this signature in database
GPG Key ID: 9DD8DA583B28154A
4 changed files with 18 additions and 2 deletions

View File

@ -3,6 +3,7 @@ import { firstValueFrom } from "rxjs";
import { LoginComponentService, PasswordPolicies } from "@bitwarden/auth/angular";
import { SsoLoginServiceAbstraction } from "@bitwarden/common/auth/abstractions/sso-login.service.abstraction";
import { ClientType } from "@bitwarden/common/enums";
import { CryptoFunctionService } from "@bitwarden/common/platform/abstractions/crypto-function.service";
import { EnvironmentService } from "@bitwarden/common/platform/abstractions/environment.service";
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
@ -10,6 +11,8 @@ import { Utils } from "@bitwarden/common/platform/misc/utils";
import { PasswordGenerationServiceAbstraction } from "@bitwarden/generator-legacy";
export class DefaultLoginComponentService implements LoginComponentService {
protected clientType: ClientType;
constructor(
protected cryptoFunctionService: CryptoFunctionService,
protected environmentService: EnvironmentService,
@ -31,6 +34,10 @@ export class DefaultLoginComponentService implements LoginComponentService {
return false;
}
isLoginWithPasskeySupported(): boolean {
return this.clientType == ClientType.Web;
}
async launchSsoBrowserWindow(
email: string,
clientId: "browser" | "desktop",

View File

@ -36,6 +36,11 @@ export abstract class LoginComponentService {
*/
isLoginViaAuthRequestSupported: () => boolean;
/**
* Indicates whether login with passkey is supported on the given client
*/
isLoginWithPasskeySupported: () => boolean;
/**
* Launches the SSO flow in a new browser window.
* - Used by: Browser, Desktop

View File

@ -39,8 +39,8 @@
<div class="tw-text-center">{{ "or" | i18n }}</div>
<!-- Link to Login with Passkey page (Web and Desktop only) -->
<ng-container *ngIf="clientType !== ClientType.Browser">
<!-- Link to Login with Passkey page (Browser only) -->
<ng-container *ngIf="isLoginWithPasskeySupported()">
<a
bitButton
block

View File

@ -375,6 +375,10 @@ export class LoginComponent implements OnInit, OnDestroy {
this.loginEmailService.setLoginEmail(this.formGroup.value.email);
}
isLoginWithPasskeySupported() {
return this.loginComponentService.isLoginWithPasskeySupported();
}
protected async goToHint(): Promise<void> {
await this.saveEmailSettings();
await this.router.navigateByUrl("/hint");