mirror of
https://github.com/bitwarden/browser
synced 2025-12-17 00:33:44 +00:00
Add isLoginWithPasskeySupported function to reduce client type checking in template.
This commit is contained in:
@@ -3,6 +3,7 @@ import { firstValueFrom } from "rxjs";
|
|||||||
|
|
||||||
import { LoginComponentService, PasswordPolicies } from "@bitwarden/auth/angular";
|
import { LoginComponentService, PasswordPolicies } from "@bitwarden/auth/angular";
|
||||||
import { SsoLoginServiceAbstraction } from "@bitwarden/common/auth/abstractions/sso-login.service.abstraction";
|
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 { CryptoFunctionService } from "@bitwarden/common/platform/abstractions/crypto-function.service";
|
||||||
import { EnvironmentService } from "@bitwarden/common/platform/abstractions/environment.service";
|
import { EnvironmentService } from "@bitwarden/common/platform/abstractions/environment.service";
|
||||||
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.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";
|
import { PasswordGenerationServiceAbstraction } from "@bitwarden/generator-legacy";
|
||||||
|
|
||||||
export class DefaultLoginComponentService implements LoginComponentService {
|
export class DefaultLoginComponentService implements LoginComponentService {
|
||||||
|
protected clientType: ClientType;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
protected cryptoFunctionService: CryptoFunctionService,
|
protected cryptoFunctionService: CryptoFunctionService,
|
||||||
protected environmentService: EnvironmentService,
|
protected environmentService: EnvironmentService,
|
||||||
@@ -31,6 +34,10 @@ export class DefaultLoginComponentService implements LoginComponentService {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isLoginWithPasskeySupported(): boolean {
|
||||||
|
return this.clientType == ClientType.Web;
|
||||||
|
}
|
||||||
|
|
||||||
async launchSsoBrowserWindow(
|
async launchSsoBrowserWindow(
|
||||||
email: string,
|
email: string,
|
||||||
clientId: "browser" | "desktop",
|
clientId: "browser" | "desktop",
|
||||||
|
|||||||
@@ -36,6 +36,11 @@ export abstract class LoginComponentService {
|
|||||||
*/
|
*/
|
||||||
isLoginViaAuthRequestSupported: () => boolean;
|
isLoginViaAuthRequestSupported: () => boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates whether login with passkey is supported on the given client
|
||||||
|
*/
|
||||||
|
isLoginWithPasskeySupported: () => boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Launches the SSO flow in a new browser window.
|
* Launches the SSO flow in a new browser window.
|
||||||
* - Used by: Browser, Desktop
|
* - Used by: Browser, Desktop
|
||||||
|
|||||||
@@ -39,8 +39,8 @@
|
|||||||
|
|
||||||
<div class="tw-text-center">{{ "or" | i18n }}</div>
|
<div class="tw-text-center">{{ "or" | i18n }}</div>
|
||||||
|
|
||||||
<!-- Link to Login with Passkey page (Web and Desktop only) -->
|
<!-- Link to Login with Passkey page (Browser only) -->
|
||||||
<ng-container *ngIf="clientType !== ClientType.Browser">
|
<ng-container *ngIf="isLoginWithPasskeySupported()">
|
||||||
<a
|
<a
|
||||||
bitButton
|
bitButton
|
||||||
block
|
block
|
||||||
|
|||||||
@@ -375,6 +375,10 @@ export class LoginComponent implements OnInit, OnDestroy {
|
|||||||
this.loginEmailService.setLoginEmail(this.formGroup.value.email);
|
this.loginEmailService.setLoginEmail(this.formGroup.value.email);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isLoginWithPasskeySupported() {
|
||||||
|
return this.loginComponentService.isLoginWithPasskeySupported();
|
||||||
|
}
|
||||||
|
|
||||||
protected async goToHint(): Promise<void> {
|
protected async goToHint(): Promise<void> {
|
||||||
await this.saveEmailSettings();
|
await this.saveEmailSettings();
|
||||||
await this.router.navigateByUrl("/hint");
|
await this.router.navigateByUrl("/hint");
|
||||||
|
|||||||
Reference in New Issue
Block a user