1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-21 11:35:34 +01:00

Remove showPasswordless conditionals (#11928)

Co-authored-by: Matt Bishop <mbishop@bitwarden.com>
This commit is contained in:
Todd Martin 2024-11-15 12:34:02 -05:00 committed by GitHub
parent d55c8712ac
commit 0308e6e180
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
26 changed files with 18 additions and 113 deletions

View File

@ -1,7 +1,6 @@
{ {
"devFlags": {}, "devFlags": {},
"flags": { "flags": {
"showPasswordless": true,
"accountSwitching": false, "accountSwitching": false,
"sdk": true "sdk": true
} }

View File

@ -6,7 +6,6 @@
"skipWelcomeOnInstall": true "skipWelcomeOnInstall": true
}, },
"flags": { "flags": {
"showPasswordless": true,
"accountSwitching": true "accountSwitching": true
} }
} }

View File

@ -64,7 +64,7 @@
> >
<i class="bwi bwi-spinner bwi-lg bwi-spin" [hidden]="!form.loading" aria-hidden="true"></i> <i class="bwi bwi-spinner bwi-lg bwi-spin" [hidden]="!form.loading" aria-hidden="true"></i>
</button> </button>
<div class="tw-mb-3" *ngIf="showLoginWithDevice && showPasswordless"> <div class="tw-mb-3" *ngIf="showLoginWithDevice">
<button type="button" class="btn block" (click)="startAuthRequestLogin()"> <button type="button" class="btn block" (click)="startAuthRequestLogin()">
<span> <i class="bwi bwi-mobile"></i> {{ "loginWithDevice" | i18n }} </span> <span> <i class="bwi bwi-mobile"></i> {{ "loginWithDevice" | i18n }} </span>
</button> </button>

View File

@ -25,14 +25,11 @@ import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.serv
import { ToastService } from "@bitwarden/components"; import { ToastService } from "@bitwarden/components";
import { PasswordGenerationServiceAbstraction } from "@bitwarden/generator-legacy"; import { PasswordGenerationServiceAbstraction } from "@bitwarden/generator-legacy";
import { flagEnabled } from "../../platform/flags";
@Component({ @Component({
selector: "app-login", selector: "app-login",
templateUrl: "login-v1.component.html", templateUrl: "login-v1.component.html",
}) })
export class LoginComponentV1 extends BaseLoginComponent implements OnInit { export class LoginComponentV1 extends BaseLoginComponent implements OnInit {
showPasswordless = false;
constructor( constructor(
devicesApiService: DevicesApiServiceAbstraction, devicesApiService: DevicesApiServiceAbstraction,
appIdService: AppIdService, appIdService: AppIdService,
@ -82,14 +79,11 @@ export class LoginComponentV1 extends BaseLoginComponent implements OnInit {
await syncService.fullSync(true); await syncService.fullSync(true);
}; };
this.successRoute = "/tabs/vault"; this.successRoute = "/tabs/vault";
this.showPasswordless = flagEnabled("showPasswordless");
} }
async ngOnInit(): Promise<void> { async ngOnInit(): Promise<void> {
await super.ngOnInit(); await super.ngOnInit();
if (this.showPasswordless) { await this.validateEmail();
await this.validateEmail();
}
} }
settings() { settings() {

View File

@ -8,7 +8,6 @@ import { EnvironmentService } from "@bitwarden/common/platform/abstractions/envi
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service"; import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
import { PasswordGenerationServiceAbstraction } from "@bitwarden/generator-legacy"; import { PasswordGenerationServiceAbstraction } from "@bitwarden/generator-legacy";
import { flagEnabled } from "../../../platform/flags";
import { BrowserPlatformUtilsService } from "../../../platform/services/platform-utils/browser-platform-utils.service"; import { BrowserPlatformUtilsService } from "../../../platform/services/platform-utils/browser-platform-utils.service";
import { ExtensionAnonLayoutWrapperDataService } from "../extension-anon-layout-wrapper/extension-anon-layout-wrapper-data.service"; import { ExtensionAnonLayoutWrapperDataService } from "../extension-anon-layout-wrapper/extension-anon-layout-wrapper-data.service";
@ -62,18 +61,6 @@ describe("ExtensionLoginComponentService", () => {
expect(service).toBeTruthy(); expect(service).toBeTruthy();
}); });
describe("isLoginViaAuthRequestSupported", () => {
it("returns true if showPasswordless flag is enabled", () => {
(flagEnabled as jest.Mock).mockReturnValue(true);
expect(service.isLoginViaAuthRequestSupported()).toBe(true);
});
it("returns false if showPasswordless flag is disabled", () => {
(flagEnabled as jest.Mock).mockReturnValue(false);
expect(service.isLoginViaAuthRequestSupported()).toBeFalsy();
});
});
describe("showBackButton", () => { describe("showBackButton", () => {
it("sets showBackButton in extensionAnonLayoutWrapperDataService", () => { it("sets showBackButton in extensionAnonLayoutWrapperDataService", () => {
service.showBackButton(true); service.showBackButton(true);

View File

@ -7,7 +7,6 @@ import { EnvironmentService } from "@bitwarden/common/platform/abstractions/envi
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service"; import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
import { PasswordGenerationServiceAbstraction } from "@bitwarden/generator-legacy"; import { PasswordGenerationServiceAbstraction } from "@bitwarden/generator-legacy";
import { flagEnabled } from "../../../platform/flags";
import { ExtensionAnonLayoutWrapperDataService } from "../extension-anon-layout-wrapper/extension-anon-layout-wrapper-data.service"; import { ExtensionAnonLayoutWrapperDataService } from "../extension-anon-layout-wrapper/extension-anon-layout-wrapper-data.service";
@Injectable() @Injectable()
@ -33,10 +32,6 @@ export class ExtensionLoginComponentService
this.clientType = this.platformUtilsService.getClientType(); this.clientType = this.platformUtilsService.getClientType();
} }
isLoginViaAuthRequestSupported(): boolean {
return flagEnabled("showPasswordless");
}
showBackButton(showBackButton: boolean): void { showBackButton(showBackButton: boolean): void {
this.extensionAnonLayoutWrapperDataService.setAnonLayoutWrapperData({ showBackButton }); this.extensionAnonLayoutWrapperDataService.setAnonLayoutWrapperData({ showBackButton });
} }

View File

@ -71,8 +71,4 @@ export class DesktopLoginComponentService
}); });
} }
} }
isLoginViaAuthRequestSupported(): boolean {
return true;
}
} }

View File

@ -11,7 +11,6 @@
"allowedHosts": "auto" "allowedHosts": "auto"
}, },
"flags": { "flags": {
"showPasswordless": false,
"sdk": true "sdk": true
}, },
"devFlags": {} "devFlags": {}

View File

@ -16,7 +16,5 @@
"proxyEvents": "https://events.bitwarden.com", "proxyEvents": "https://events.bitwarden.com",
"proxyNotifications": "https://notifications.bitwarden.com" "proxyNotifications": "https://notifications.bitwarden.com"
}, },
"flags": { "flags": {}
"showPasswordless": true
}
} }

View File

@ -19,8 +19,6 @@
} }
} }
], ],
"flags": { "flags": {},
"showPasswordless": true
},
"devFlags": {} "devFlags": {}
} }

View File

@ -10,7 +10,5 @@
"businessId": "4ZDA7DLUUJGMN", "businessId": "4ZDA7DLUUJGMN",
"buttonAction": "https://www.paypal.com/cgi-bin/webscr" "buttonAction": "https://www.paypal.com/cgi-bin/webscr"
}, },
"flags": { "flags": {}
"showPasswordless": true
}
} }

View File

@ -20,7 +20,5 @@
} }
} }
], ],
"flags": { "flags": {}
"showPasswordless": true
}
} }

View File

@ -26,7 +26,5 @@
} }
} }
], ],
"flags": { "flags": {}
"showPasswordless": true
}
} }

View File

@ -6,7 +6,5 @@
"proxyNotifications": "http://localhost:61841", "proxyNotifications": "http://localhost:61841",
"port": 8081 "port": 8081
}, },
"flags": { "flags": {}
"showPasswordless": true
}
} }

View File

@ -13,7 +13,5 @@
} }
} }
], ],
"flags": { "flags": {}
"showPasswordless": true
}
} }

View File

@ -16,7 +16,6 @@ import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/pl
import { PasswordGenerationServiceAbstraction } from "@bitwarden/generator-legacy"; import { PasswordGenerationServiceAbstraction } from "@bitwarden/generator-legacy";
import { RouterService } from "../../../../../../../../apps/web/src/app/core"; import { RouterService } from "../../../../../../../../apps/web/src/app/core";
import { flagEnabled } from "../../../../../utils/flags";
import { AcceptOrganizationInviteService } from "../../../organization-invite/accept-organization.service"; import { AcceptOrganizationInviteService } from "../../../organization-invite/accept-organization.service";
import { WebLoginComponentService } from "./web-login-component.service"; import { WebLoginComponentService } from "./web-login-component.service";
@ -73,18 +72,6 @@ describe("WebLoginComponentService", () => {
expect(service).toBeTruthy(); expect(service).toBeTruthy();
}); });
describe("isLoginViaAuthRequestSupported", () => {
it("returns true if showPasswordless flag is enabled", () => {
(flagEnabled as jest.Mock).mockReturnValue(true);
expect(service.isLoginViaAuthRequestSupported()).toBe(true);
});
it("returns false if showPasswordless flag is disabled", () => {
(flagEnabled as jest.Mock).mockReturnValue(false);
expect(service.isLoginViaAuthRequestSupported()).toBeFalsy();
});
});
describe("getOrgPolicies", () => { describe("getOrgPolicies", () => {
it("returns undefined if organization invite is null", async () => { it("returns undefined if organization invite is null", async () => {
acceptOrganizationInviteService.getOrganizationInvite.mockResolvedValue(null); acceptOrganizationInviteService.getOrganizationInvite.mockResolvedValue(null);

View File

@ -16,7 +16,6 @@ import { LogService } from "@bitwarden/common/platform/abstractions/log.service"
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service"; import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
import { PasswordGenerationServiceAbstraction } from "@bitwarden/generator-legacy"; import { PasswordGenerationServiceAbstraction } from "@bitwarden/generator-legacy";
import { flagEnabled } from "../../../../../utils/flags";
import { RouterService } from "../../../../core/router.service"; import { RouterService } from "../../../../core/router.service";
import { AcceptOrganizationInviteService } from "../../../organization-invite/accept-organization.service"; import { AcceptOrganizationInviteService } from "../../../organization-invite/accept-organization.service";
@ -47,10 +46,6 @@ export class WebLoginComponentService
this.clientType = this.platformUtilsService.getClientType(); this.clientType = this.platformUtilsService.getClientType();
} }
isLoginViaAuthRequestSupported(): boolean {
return flagEnabled("showPasswordless");
}
async getOrgPolicies(): Promise<PasswordPolicies | null> { async getOrgPolicies(): Promise<PasswordPolicies | null> {
const orgInvite = await this.acceptOrganizationInviteService.getOrganizationInvite(); const orgInvite = await this.acceptOrganizationInviteService.getOrganizationInvite();

View File

@ -92,7 +92,7 @@
</button> </button>
</div> </div>
<div class="tw-mb-3" *ngIf="showLoginWithDevice && showPasswordless"> <div class="tw-mb-3" *ngIf="showLoginWithDevice">
<button <button
bitButton bitButton
type="button" type="button"

View File

@ -32,7 +32,6 @@ import { UserId } from "@bitwarden/common/types/guid";
import { ToastService } from "@bitwarden/components"; import { ToastService } from "@bitwarden/components";
import { PasswordGenerationServiceAbstraction } from "@bitwarden/generator-legacy"; import { PasswordGenerationServiceAbstraction } from "@bitwarden/generator-legacy";
import { flagEnabled } from "../../../utils/flags";
import { RouterService } from "../../core"; import { RouterService } from "../../core";
import { AcceptOrganizationInviteService } from "../organization-invite/accept-organization.service"; import { AcceptOrganizationInviteService } from "../organization-invite/accept-organization.service";
import { OrganizationInvite } from "../organization-invite/organization-invite"; import { OrganizationInvite } from "../organization-invite/organization-invite";
@ -46,7 +45,6 @@ export class LoginComponentV1 extends BaseLoginComponent implements OnInit {
showResetPasswordAutoEnrollWarning = false; showResetPasswordAutoEnrollWarning = false;
enforcedPasswordPolicyOptions: MasterPasswordPolicyOptions; enforcedPasswordPolicyOptions: MasterPasswordPolicyOptions;
policies: Policy[]; policies: Policy[];
showPasswordless = false;
constructor( constructor(
private acceptOrganizationInviteService: AcceptOrganizationInviteService, private acceptOrganizationInviteService: AcceptOrganizationInviteService,
@ -98,7 +96,6 @@ export class LoginComponentV1 extends BaseLoginComponent implements OnInit {
toastService, toastService,
); );
this.onSuccessfulLoginNavigate = this.goAfterLogIn; this.onSuccessfulLoginNavigate = this.goAfterLogIn;
this.showPasswordless = flagEnabled("showPasswordless");
} }
submitForm = async (showToast = true) => { submitForm = async (showToast = true) => {

View File

@ -8,9 +8,7 @@ import {
// required to avoid linting errors when there are no flags // required to avoid linting errors when there are no flags
// eslint-disable-next-line @typescript-eslint/ban-types // eslint-disable-next-line @typescript-eslint/ban-types
export type Flags = { export type Flags = {} & SharedFlags;
showPasswordless?: boolean;
} & SharedFlags;
// required to avoid linting errors when there are no flags // required to avoid linting errors when there are no flags
// eslint-disable-next-line @typescript-eslint/ban-types // eslint-disable-next-line @typescript-eslint/ban-types

View File

@ -63,12 +63,6 @@ describe("DefaultLoginComponentService", () => {
}); });
}); });
describe("isLoginViaAuthRequestSupported", () => {
it("returns false by default", () => {
expect(service.isLoginViaAuthRequestSupported()).toBe(false);
});
});
describe("isLoginWithPasskeySupported", () => { describe("isLoginWithPasskeySupported", () => {
it("returns true when clientType is Web", () => { it("returns true when clientType is Web", () => {
service["clientType"] = ClientType.Web; service["clientType"] = ClientType.Web;

View File

@ -25,10 +25,6 @@ export class DefaultLoginComponentService implements LoginComponentService {
return null; return null;
} }
isLoginViaAuthRequestSupported(): boolean {
return false;
}
isLoginWithPasskeySupported(): boolean { isLoginWithPasskeySupported(): boolean {
return this.clientType === ClientType.Web; return this.clientType === ClientType.Web;
} }

View File

@ -23,11 +23,6 @@ export abstract class LoginComponentService {
*/ */
getOrgPolicies: () => Promise<PasswordPolicies | null>; getOrgPolicies: () => Promise<PasswordPolicies | null>;
/**
* Indicates whether login with device (auth request) is supported on the given client
*/
isLoginViaAuthRequestSupported: () => boolean;
/** /**
* Indicates whether login with passkey is supported on the given client * Indicates whether login with passkey is supported on the given client
*/ */

View File

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

View File

@ -104,12 +104,6 @@ export class LoginComponent implements OnInit, OnDestroy {
return this.formGroup.controls.email; return this.formGroup.controls.email;
} }
/**
* LoginViaAuthRequestSupported is a boolean that determines if we show the Login with device button.
* An AuthRequest is the mechanism that allows users to login to the client via a device that is already logged in.
*/
loginViaAuthRequestSupported = false;
// Web properties // Web properties
enforcedPasswordPolicyOptions: MasterPasswordPolicyOptions; enforcedPasswordPolicyOptions: MasterPasswordPolicyOptions;
policies: Policy[]; policies: Policy[];
@ -144,7 +138,6 @@ export class LoginComponent implements OnInit, OnDestroy {
private configService: ConfigService, private configService: ConfigService,
) { ) {
this.clientType = this.platformUtilsService.getClientType(); this.clientType = this.platformUtilsService.getClientType();
this.loginViaAuthRequestSupported = this.loginComponentService.isLoginViaAuthRequestSupported();
} }
async ngOnInit(): Promise<void> { async ngOnInit(): Promise<void> {
@ -402,10 +395,8 @@ export class LoginComponent implements OnInit, OnDestroy {
// Reset master password only when going from validated to not validated so that autofill can work properly // Reset master password only when going from validated to not validated so that autofill can work properly
this.formGroup.controls.masterPassword.reset(); this.formGroup.controls.masterPassword.reset();
if (this.loginViaAuthRequestSupported) { // Reset known device state when going back to email entry if it is supported
// Reset known device state when going back to email entry if it is supported this.isKnownDevice = false;
this.isKnownDevice = false;
}
} else if (this.loginUiState === LoginUiState.MASTER_PASSWORD_ENTRY) { } else if (this.loginUiState === LoginUiState.MASTER_PASSWORD_ENTRY) {
this.loginComponentService.showBackButton(true); this.loginComponentService.showBackButton(true);
this.anonLayoutWrapperDataService.setAnonLayoutWrapperData({ this.anonLayoutWrapperDataService.setAnonLayoutWrapperData({
@ -426,9 +417,8 @@ export class LoginComponent implements OnInit, OnDestroy {
}); });
} }
if (this.loginViaAuthRequestSupported) { // Check to see if the device is known so we can show the Login with Device option
await this.getKnownDevice(this.emailFormControl.value); await this.getKnownDevice(this.emailFormControl.value);
}
} }
} }
@ -580,9 +570,8 @@ export class LoginComponent implements OnInit, OnDestroy {
await this.loadEmailSettings(); await this.loadEmailSettings();
} }
if (this.loginViaAuthRequestSupported) { // Check to see if the device is known so that we can show the Login with Device option
await this.getKnownDevice(this.emailFormControl.value); await this.getKnownDevice(this.emailFormControl.value);
}
// Backup check to handle unknown case where activatedRoute is not available // Backup check to handle unknown case where activatedRoute is not available
// This shouldn't happen under normal circumstances // This shouldn't happen under normal circumstances

View File

@ -1,7 +1,6 @@
// required to avoid linting errors when there are no flags // required to avoid linting errors when there are no flags
// eslint-disable-next-line @typescript-eslint/ban-types // eslint-disable-next-line @typescript-eslint/ban-types
export type SharedFlags = { export type SharedFlags = {
showPasswordless?: boolean;
sdk?: boolean; sdk?: boolean;
prereleaseBuild?: boolean; prereleaseBuild?: boolean;
}; };