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 extends DefaultLoginComponentService
implements LoginComponentService implements LoginComponentService
{ {
getShowPasswordlessFlag(): boolean { isLoginViaAuthRequestSupported(): boolean {
return flagEnabled("showPasswordless"); return flagEnabled("showPasswordless");
} }
} }

View File

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

View File

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

View File

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

View File

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

View File

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