Skip to content

Commit

Permalink
Remove showPasswordless conditionals (#11928)
Browse files Browse the repository at this point in the history
Co-authored-by: Matt Bishop <[email protected]>
  • Loading branch information
trmartin4 and withinfocus authored Nov 15, 2024
1 parent d55c871 commit 0308e6e
Show file tree
Hide file tree
Showing 26 changed files with 18 additions and 113 deletions.
1 change: 0 additions & 1 deletion apps/browser/config/base.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"devFlags": {},
"flags": {
"showPasswordless": true,
"accountSwitching": false,
"sdk": true
}
Expand Down
1 change: 0 additions & 1 deletion apps/browser/config/development.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"skipWelcomeOnInstall": true
},
"flags": {
"showPasswordless": true,
"accountSwitching": true
}
}
2 changes: 1 addition & 1 deletion apps/browser/src/auth/popup/login-v1.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ <h1 class="login-center">
>
<i class="bwi bwi-spinner bwi-lg bwi-spin" [hidden]="!form.loading" aria-hidden="true"></i>
</button>
<div class="tw-mb-3" *ngIf="showLoginWithDevice && showPasswordless">
<div class="tw-mb-3" *ngIf="showLoginWithDevice">
<button type="button" class="btn block" (click)="startAuthRequestLogin()">
<span> <i class="bwi bwi-mobile"></i> {{ "loginWithDevice" | i18n }} </span>
</button>
Expand Down
8 changes: 1 addition & 7 deletions apps/browser/src/auth/popup/login-v1.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,11 @@ import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.serv
import { ToastService } from "@bitwarden/components";
import { PasswordGenerationServiceAbstraction } from "@bitwarden/generator-legacy";

import { flagEnabled } from "../../platform/flags";

@Component({
selector: "app-login",
templateUrl: "login-v1.component.html",
})
export class LoginComponentV1 extends BaseLoginComponent implements OnInit {
showPasswordless = false;
constructor(
devicesApiService: DevicesApiServiceAbstraction,
appIdService: AppIdService,
Expand Down Expand Up @@ -82,14 +79,11 @@ export class LoginComponentV1 extends BaseLoginComponent implements OnInit {
await syncService.fullSync(true);
};
this.successRoute = "/tabs/vault";
this.showPasswordless = flagEnabled("showPasswordless");
}

async ngOnInit(): Promise<void> {
await super.ngOnInit();
if (this.showPasswordless) {
await this.validateEmail();
}
await this.validateEmail();
}

settings() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { EnvironmentService } from "@bitwarden/common/platform/abstractions/envi
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
import { PasswordGenerationServiceAbstraction } from "@bitwarden/generator-legacy";

import { flagEnabled } from "../../../platform/flags";
import { BrowserPlatformUtilsService } from "../../../platform/services/platform-utils/browser-platform-utils.service";
import { ExtensionAnonLayoutWrapperDataService } from "../extension-anon-layout-wrapper/extension-anon-layout-wrapper-data.service";

Expand Down Expand Up @@ -62,18 +61,6 @@ describe("ExtensionLoginComponentService", () => {
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", () => {
it("sets showBackButton in extensionAnonLayoutWrapperDataService", () => {
service.showBackButton(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { EnvironmentService } from "@bitwarden/common/platform/abstractions/envi
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
import { PasswordGenerationServiceAbstraction } from "@bitwarden/generator-legacy";

import { flagEnabled } from "../../../platform/flags";
import { ExtensionAnonLayoutWrapperDataService } from "../extension-anon-layout-wrapper/extension-anon-layout-wrapper-data.service";

@Injectable()
Expand All @@ -33,10 +32,6 @@ export class ExtensionLoginComponentService
this.clientType = this.platformUtilsService.getClientType();
}

isLoginViaAuthRequestSupported(): boolean {
return flagEnabled("showPasswordless");
}

showBackButton(showBackButton: boolean): void {
this.extensionAnonLayoutWrapperDataService.setAnonLayoutWrapperData({ showBackButton });
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,4 @@ export class DesktopLoginComponentService
});
}
}

isLoginViaAuthRequestSupported(): boolean {
return true;
}
}
1 change: 0 additions & 1 deletion apps/web/config/base.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"allowedHosts": "auto"
},
"flags": {
"showPasswordless": false,
"sdk": true
},
"devFlags": {}
Expand Down
4 changes: 1 addition & 3 deletions apps/web/config/cloud.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,5 @@
"proxyEvents": "https://events.bitwarden.com",
"proxyNotifications": "https://notifications.bitwarden.com"
},
"flags": {
"showPasswordless": true
}
"flags": {}
}
4 changes: 1 addition & 3 deletions apps/web/config/development.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
}
}
],
"flags": {
"showPasswordless": true
},
"flags": {},
"devFlags": {}
}
4 changes: 1 addition & 3 deletions apps/web/config/euprd.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,5 @@
"businessId": "4ZDA7DLUUJGMN",
"buttonAction": "https://www.paypal.com/cgi-bin/webscr"
},
"flags": {
"showPasswordless": true
}
"flags": {}
}
4 changes: 1 addition & 3 deletions apps/web/config/euqa.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,5 @@
}
}
],
"flags": {
"showPasswordless": true
}
"flags": {}
}
4 changes: 1 addition & 3 deletions apps/web/config/qa.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,5 @@
}
}
],
"flags": {
"showPasswordless": true
}
"flags": {}
}
4 changes: 1 addition & 3 deletions apps/web/config/selfhosted.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,5 @@
"proxyNotifications": "http://localhost:61841",
"port": 8081
},
"flags": {
"showPasswordless": true
}
"flags": {}
}
4 changes: 1 addition & 3 deletions apps/web/config/usdev.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,5 @@
}
}
],
"flags": {
"showPasswordless": true
}
"flags": {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/pl
import { PasswordGenerationServiceAbstraction } from "@bitwarden/generator-legacy";

import { RouterService } from "../../../../../../../../apps/web/src/app/core";
import { flagEnabled } from "../../../../../utils/flags";
import { AcceptOrganizationInviteService } from "../../../organization-invite/accept-organization.service";

import { WebLoginComponentService } from "./web-login-component.service";
Expand Down Expand Up @@ -73,18 +72,6 @@ describe("WebLoginComponentService", () => {
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", () => {
it("returns undefined if organization invite is null", async () => {
acceptOrganizationInviteService.getOrganizationInvite.mockResolvedValue(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import { LogService } from "@bitwarden/common/platform/abstractions/log.service"
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
import { PasswordGenerationServiceAbstraction } from "@bitwarden/generator-legacy";

import { flagEnabled } from "../../../../../utils/flags";
import { RouterService } from "../../../../core/router.service";
import { AcceptOrganizationInviteService } from "../../../organization-invite/accept-organization.service";

Expand Down Expand Up @@ -47,10 +46,6 @@ export class WebLoginComponentService
this.clientType = this.platformUtilsService.getClientType();
}

isLoginViaAuthRequestSupported(): boolean {
return flagEnabled("showPasswordless");
}

async getOrgPolicies(): Promise<PasswordPolicies | null> {
const orgInvite = await this.acceptOrganizationInviteService.getOrganizationInvite();

Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/app/auth/login/login-v1.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
</button>
</div>

<div class="tw-mb-3" *ngIf="showLoginWithDevice && showPasswordless">
<div class="tw-mb-3" *ngIf="showLoginWithDevice">
<button
bitButton
type="button"
Expand Down
3 changes: 0 additions & 3 deletions apps/web/src/app/auth/login/login-v1.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import { UserId } from "@bitwarden/common/types/guid";
import { ToastService } from "@bitwarden/components";
import { PasswordGenerationServiceAbstraction } from "@bitwarden/generator-legacy";

import { flagEnabled } from "../../../utils/flags";
import { RouterService } from "../../core";
import { AcceptOrganizationInviteService } from "../organization-invite/accept-organization.service";
import { OrganizationInvite } from "../organization-invite/organization-invite";
Expand All @@ -46,7 +45,6 @@ export class LoginComponentV1 extends BaseLoginComponent implements OnInit {
showResetPasswordAutoEnrollWarning = false;
enforcedPasswordPolicyOptions: MasterPasswordPolicyOptions;
policies: Policy[];
showPasswordless = false;

constructor(
private acceptOrganizationInviteService: AcceptOrganizationInviteService,
Expand Down Expand Up @@ -98,7 +96,6 @@ export class LoginComponentV1 extends BaseLoginComponent implements OnInit {
toastService,
);
this.onSuccessfulLoginNavigate = this.goAfterLogIn;
this.showPasswordless = flagEnabled("showPasswordless");
}

submitForm = async (showToast = true) => {
Expand Down
4 changes: 1 addition & 3 deletions apps/web/src/utils/flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ import {

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

// required to avoid linting errors when there are no flags
// eslint-disable-next-line @typescript-eslint/ban-types
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,6 @@ describe("DefaultLoginComponentService", () => {
});
});

describe("isLoginViaAuthRequestSupported", () => {
it("returns false by default", () => {
expect(service.isLoginViaAuthRequestSupported()).toBe(false);
});
});

describe("isLoginWithPasskeySupported", () => {
it("returns true when clientType is Web", () => {
service["clientType"] = ClientType.Web;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ export class DefaultLoginComponentService implements LoginComponentService {
return null;
}

isLoginViaAuthRequestSupported(): boolean {
return false;
}

isLoginWithPasskeySupported(): boolean {
return this.clientType === ClientType.Web;
}
Expand Down
5 changes: 0 additions & 5 deletions libs/auth/src/angular/login/login-component.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@ export abstract class LoginComponentService {
*/
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
*/
Expand Down
2 changes: 1 addition & 1 deletion libs/auth/src/angular/login/login.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
</button>

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

<button
Expand Down
23 changes: 6 additions & 17 deletions libs/auth/src/angular/login/login.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,6 @@ export class LoginComponent implements OnInit, OnDestroy {
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
enforcedPasswordPolicyOptions: MasterPasswordPolicyOptions;
policies: Policy[];
Expand Down Expand Up @@ -144,7 +138,6 @@ export class LoginComponent implements OnInit, OnDestroy {
private configService: ConfigService,
) {
this.clientType = this.platformUtilsService.getClientType();
this.loginViaAuthRequestSupported = this.loginComponentService.isLoginViaAuthRequestSupported();
}

async ngOnInit(): Promise<void> {
Expand Down Expand Up @@ -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
this.formGroup.controls.masterPassword.reset();

if (this.loginViaAuthRequestSupported) {
// Reset known device state when going back to email entry if it is supported
this.isKnownDevice = false;
}
// Reset known device state when going back to email entry if it is supported
this.isKnownDevice = false;
} else if (this.loginUiState === LoginUiState.MASTER_PASSWORD_ENTRY) {
this.loginComponentService.showBackButton(true);
this.anonLayoutWrapperDataService.setAnonLayoutWrapperData({
Expand All @@ -426,9 +417,8 @@ export class LoginComponent implements OnInit, OnDestroy {
});
}

if (this.loginViaAuthRequestSupported) {
await this.getKnownDevice(this.emailFormControl.value);
}
// Check to see if the device is known so we can show the Login with Device option
await this.getKnownDevice(this.emailFormControl.value);
}
}

Expand Down Expand Up @@ -580,9 +570,8 @@ export class LoginComponent implements OnInit, OnDestroy {
await this.loadEmailSettings();
}

if (this.loginViaAuthRequestSupported) {
await this.getKnownDevice(this.emailFormControl.value);
}
// Check to see if the device is known so that we can show the Login with Device option
await this.getKnownDevice(this.emailFormControl.value);

// Backup check to handle unknown case where activatedRoute is not available
// This shouldn't happen under normal circumstances
Expand Down
1 change: 0 additions & 1 deletion libs/common/src/platform/misc/flags.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// required to avoid linting errors when there are no flags
// eslint-disable-next-line @typescript-eslint/ban-types
export type SharedFlags = {
showPasswordless?: boolean;
sdk?: boolean;
prereleaseBuild?: boolean;
};
Expand Down

0 comments on commit 0308e6e

Please sign in to comment.