PM-8111 - New Login Comp + Login Comp Svc - (1) Refactor naming and returns of getShowPasswordlessFlag to isLoginViaAuthRequestSupported (2) Replace showPasswordless with better composed variable names.

This commit is contained in:
Jared Snider 2024-09-30 15:30:31 -04:00
parent 79b2633d9e
commit d1a0c2f5f5
No known key found for this signature in database
GPG Key ID: A149DDD612516286
6 changed files with 13 additions and 17 deletions

View File

@ -6,7 +6,7 @@ export class ExtensionLoginComponentService
extends DefaultLoginComponentService
implements LoginComponentService
{
getShowPasswordlessFlag(): boolean {
isLoginViaAuthRequestSupported(): boolean {
return flagEnabled("showPasswordless");
}
}

View File

@ -27,7 +27,7 @@ export class WebLoginComponentService
router = inject(Router);
routerService = inject(RouterService);
getShowPasswordlessFlag(): boolean {
isLoginViaAuthRequestSupported(): boolean {
return flagEnabled("showPasswordless");
}

View File

@ -27,8 +27,8 @@ export class DefaultLoginComponentService implements LoginComponentService {
return null;
}
getShowPasswordlessFlag(): boolean {
return null;
isLoginViaAuthRequestSupported(): boolean {
return false;
}
async launchSsoBrowserWindow(

View File

@ -32,10 +32,9 @@ export abstract class LoginComponentService {
setPreviousUrl: (route: UrlTree) => void | null;
/**
* Gets the status of the `showPasswordless` feature flag.
* - Used by: Web, Browser
* Indicates whether login with device (auth request) is supported on the given client
*/
getShowPasswordlessFlag: () => boolean;
isLoginViaAuthRequestSupported: () => boolean;
/**
* Launches the SSO flow in a new browser window.

View File

@ -117,7 +117,7 @@
</button>
<!-- Button to Login with Device -->
<ng-container *ngIf="showLoginWithDevice && showPasswordless">
<ng-container *ngIf="loginViaAuthRequestSupported && isKnownDevice">
<div class="tw-text-center">{{ "or" | i18n }}</div>
<button

View File

@ -82,7 +82,7 @@ export class LoginComponent implements OnInit, OnDestroy {
ClientType = ClientType;
LoginUiState = LoginUiState;
registerRoute$ = this.registerRouteService.registerRoute$(); // TODO: remove when email verification flag is removed
showLoginWithDevice = false;
isKnownDevice = false;
validatedEmail = false;
formGroup = this.formBuilder.group(
@ -112,7 +112,7 @@ export class LoginComponent implements OnInit, OnDestroy {
// Web properties
enforcedPasswordPolicyOptions: MasterPasswordPolicyOptions;
policies: Policy[];
showPasswordless = false;
loginViaAuthRequestSupported = false;
showResetPasswordAutoEnrollWarning = false;
// Desktop properties
@ -144,7 +144,7 @@ export class LoginComponent implements OnInit, OnDestroy {
private extensionLoginService: ExtensionLoginService,
) {
this.clientType = this.platformUtilsService.getClientType();
this.showPasswordless = this.loginComponentService.getShowPasswordlessFlag();
this.loginViaAuthRequestSupported = this.loginComponentService.isLoginViaAuthRequestSupported();
}
async ngOnInit(): Promise<void> {
@ -155,7 +155,7 @@ export class LoginComponent implements OnInit, OnDestroy {
await this.defaultOnInit();
if (this.clientType === ClientType.Browser) {
if (this.showPasswordless) {
if (this.loginViaAuthRequestSupported) {
await this.validateEmail();
}
}
@ -423,12 +423,9 @@ export class LoginComponent implements OnInit, OnDestroy {
private async getLoginWithDevice(email: string): Promise<void> {
try {
const deviceIdentifier = await this.appIdService.getAppId();
this.showLoginWithDevice = await this.devicesApiService.getKnownDevice(
email,
deviceIdentifier,
);
this.isKnownDevice = await this.devicesApiService.getKnownDevice(email, deviceIdentifier);
} catch (e) {
this.showLoginWithDevice = false;
this.isKnownDevice = false;
}
}