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:
parent
a104a9250d
commit
ca0520cea0
@ -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",
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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");
|
||||
|
Loading…
Reference in New Issue
Block a user