Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(email-verification-feature-flag): [PM-7882] Email Verificati… #12718

Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
98f45e9
refactor(email-verification-feature-flag): [PM-7882] Email Verificati…
Patrick-Pimentel-Bitwarden Jan 6, 2025
a570803
refactor(email-verification-feature-flag): [PM-7882] Email Verificati…
Patrick-Pimentel-Bitwarden Jan 6, 2025
84edfc0
refactor(email-verification-feature-flag): [PM-7882] Email Verificati…
Patrick-Pimentel-Bitwarden Jan 6, 2025
0a28e6a
refactor(email-verification-feature-flag): [PM-7882] Email Verificati…
Patrick-Pimentel-Bitwarden Jan 6, 2025
acb0931
refactor(email-verification-feature-flag): [PM-7882] Email Verificati…
Patrick-Pimentel-Bitwarden Jan 6, 2025
ec28e7b
refactor(email-verification-feature-flag): [PM-7882] Email Verificati…
Patrick-Pimentel-Bitwarden Jan 8, 2025
317c197
refactor(email-verification-feature-flag): [PM-7882] Email Verificati…
Patrick-Pimentel-Bitwarden Jan 8, 2025
322ed11
fix(email-verification-feature-flag): [PM-7882] Email Verification - …
Patrick-Pimentel-Bitwarden Jan 8, 2025
a2b2d71
Merge remote-tracking branch 'origin' into auth/pm-7882/email-verific…
Patrick-Pimentel-Bitwarden Jan 9, 2025
a49ae00
Merge remote-tracking branch 'origin' into auth/pm-7882/email-verific…
Patrick-Pimentel-Bitwarden Jan 14, 2025
6417c7f
refactor(email-verification-feature-flag): [PM-7882] Email Verificati…
Patrick-Pimentel-Bitwarden Jan 14, 2025
3e153ba
fix(email-verification-feature-flag): [PM-7882] Email Verification - …
Patrick-Pimentel-Bitwarden Jan 14, 2025
29f09a0
Merge remote-tracking branch 'origin' into auth/pm-7882/email-verific…
Patrick-Pimentel-Bitwarden Jan 15, 2025
454a798
Merge remote-tracking branch 'origin' into auth/pm-7882/email-verific…
Patrick-Pimentel-Bitwarden Jan 15, 2025
c57d38e
fix(email-verification-feature-flag): [PM-7882] Email Verification - …
Patrick-Pimentel-Bitwarden Jan 15, 2025
e8da9fa
refactor(email-verification-feature-flag): [PM-7882] Email Verificati…
Patrick-Pimentel-Bitwarden Jan 16, 2025
f7672e4
fix(email-verification-feature-flag): [PM-7882] Email Verification - …
Patrick-Pimentel-Bitwarden Jan 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions apps/browser/src/auth/popup/home.component.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<app-header [noTheme]="true"> </app-header>
<app-header [noTheme]="true"></app-header>
<div class="center-content">
<div class="content login-page">
<div class="logo-image"></div>
Expand Down Expand Up @@ -30,9 +30,7 @@
</form>
<p class="createAccountLink">
{{ "newAroundHere" | i18n }}
<a [routerLink]="registerRoute$ | async" (click)="setLoginEmailValues()">{{
"createAccount" | i18n
}}</a>
<a routerLink="/signup" (click)="setLoginEmailValues()">{{ "createAccount" | i18n }}</a>
</p>
</div>
</div>
14 changes: 6 additions & 8 deletions apps/browser/src/auth/popup/home.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { ActivatedRoute, Router } from "@angular/router";
import { Subject, firstValueFrom, switchMap, takeUntil, tap } from "rxjs";

import { EnvironmentSelectorComponent } from "@bitwarden/angular/auth/components/environment-selector.component";
import { LoginEmailServiceAbstraction, RegisterRouteService } from "@bitwarden/auth/common";
import { LoginEmailServiceAbstraction } from "@bitwarden/auth/common";
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
Expand All @@ -30,17 +30,13 @@ export class HomeComponent implements OnInit, OnDestroy {
rememberEmail: [false],
});

// TODO: remove when email verification flag is removed
registerRoute$ = this.registerRouteService.registerRoute$();

constructor(
protected platformUtilsService: PlatformUtilsService,
private formBuilder: FormBuilder,
private router: Router,
private i18nService: I18nService,
private loginEmailService: LoginEmailServiceAbstraction,
private accountSwitcherService: AccountSwitcherService,
private registerRouteService: RegisterRouteService,
private toastService: ToastService,
private configService: ConfigService,
private route: ActivatedRoute,
Expand Down Expand Up @@ -118,13 +114,15 @@ export class HomeComponent implements OnInit, OnDestroy {
}

await this.setLoginEmailValues();
await this.router.navigate(["login"], { queryParams: { email: this.formGroup.value.email } });
await this.router.navigate(["login"], {
queryParams: { email: this.formGroup.controls.email.value },
});
}

async setLoginEmailValues() {
// Note: Browser saves email settings here instead of the login component
this.loginEmailService.setRememberEmail(this.formGroup.value.rememberEmail);
await this.loginEmailService.setLoginEmail(this.formGroup.value.email);
this.loginEmailService.setRememberEmail(this.formGroup.controls.rememberEmail.value);
await this.loginEmailService.setLoginEmail(this.formGroup.controls.email.value);
await this.loginEmailService.saveEmailSettings();
}
}
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
@@ -1,4 +1,4 @@
<form #form (ngSubmit)="submit()" [appApiAction]="formPromise" [formGroup]="formGroup">
<form #form (ngSubmit)="submitLogin()" [appApiAction]="formPromise" [formGroup]="formGroup">
<header>
<h1 class="login-center">
<span class="title">{{ "logIn" | i18n }}</span>
Expand Down
12 changes: 0 additions & 12 deletions apps/browser/src/auth/popup/login-v1.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@ import { FormValidationErrorsService } from "@bitwarden/angular/platform/abstrac
import {
LoginStrategyServiceAbstraction,
LoginEmailServiceAbstraction,
RegisterRouteService,
} from "@bitwarden/auth/common";
import { DevicesApiServiceAbstraction } from "@bitwarden/common/auth/abstractions/devices-api.service.abstraction";
import { SsoLoginServiceAbstraction } from "@bitwarden/common/auth/abstractions/sso-login.service.abstraction";
import { WebAuthnLoginServiceAbstraction } from "@bitwarden/common/auth/abstractions/webauthn/webauthn-login.service.abstraction";
import { AppIdService } from "@bitwarden/common/platform/abstractions/app-id.service";
import { CryptoFunctionService } from "@bitwarden/common/platform/abstractions/crypto-function.service";
import { EnvironmentService } from "@bitwarden/common/platform/abstractions/environment.service";
Expand Down Expand Up @@ -51,8 +49,6 @@ export class LoginComponentV1 extends BaseLoginComponent implements OnInit {
route: ActivatedRoute,
loginEmailService: LoginEmailServiceAbstraction,
ssoLoginService: SsoLoginServiceAbstraction,
webAuthnLoginService: WebAuthnLoginServiceAbstraction,
registerRouteService: RegisterRouteService,
toastService: ToastService,
) {
super(
Expand All @@ -73,8 +69,6 @@ export class LoginComponentV1 extends BaseLoginComponent implements OnInit {
route,
loginEmailService,
ssoLoginService,
webAuthnLoginService,
registerRouteService,
toastService,
);
this.onSuccessfulLogin = async () => {
Expand All @@ -88,12 +82,6 @@ export class LoginComponentV1 extends BaseLoginComponent implements OnInit {
await this.validateEmail();
}

settings() {
// FIXME: Verify that this floating promise is intentional. If it is, add an explanatory comment and ensure there is proper error handling.
// eslint-disable-next-line @typescript-eslint/no-floating-promises
this.router.navigate(["environment"]);
}

rr-bw marked this conversation as resolved.
Show resolved Hide resolved
async launchSsoBrowser() {
// Save off email for SSO
await this.ssoLoginService.setSsoEmail(this.formGroup.value.email);
Expand Down
7 changes: 2 additions & 5 deletions apps/browser/src/popup/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import {
tdeDecryptionRequiredGuard,
unauthGuardFn,
} from "@bitwarden/angular/auth/guards";
import { canAccessFeature } from "@bitwarden/angular/platform/guard/feature-flag.guard";
import { extensionRefreshSwap } from "@bitwarden/angular/utils/extension-refresh-swap";
import { NewDeviceVerificationNoticeGuard } from "@bitwarden/angular/vault/guards";
import {
Expand All @@ -42,7 +41,6 @@ import {
SsoComponent,
TwoFactorTimeoutIcon,
} from "@bitwarden/auth/angular";
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";
import {
NewDeviceVerificationNoticePageOneComponent,
NewDeviceVerificationNoticePageTwoComponent,
Expand Down Expand Up @@ -553,7 +551,7 @@ const routes: Routes = [
children: [
{
path: "signup",
canActivate: [canAccessFeature(FeatureFlag.EmailVerification), unauthGuardFn()],
canActivate: [unauthGuardFn()],
data: {
elevation: 1,
pageIcon: RegistrationUserAddIcon,
Expand All @@ -579,7 +577,7 @@ const routes: Routes = [
},
{
path: "finish-signup",
canActivate: [canAccessFeature(FeatureFlag.EmailVerification), unauthGuardFn()],
canActivate: [unauthGuardFn()],
data: {
pageIcon: RegistrationLockAltIcon,
elevation: 1,
Expand Down Expand Up @@ -629,7 +627,6 @@ const routes: Routes = [
children: [
{
path: "set-password-jit",
canActivate: [canAccessFeature(FeatureFlag.EmailVerification)],
component: SetPasswordJitComponent,
data: {
pageTitle: {
Expand Down
7 changes: 2 additions & 5 deletions apps/desktop/src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {
tdeDecryptionRequiredGuard,
unauthGuardFn,
} from "@bitwarden/angular/auth/guards";
import { canAccessFeature } from "@bitwarden/angular/platform/guard/feature-flag.guard";
import { NewDeviceVerificationNoticeGuard } from "@bitwarden/angular/vault/guards";
import {
AnonLayoutWrapperComponent,
Expand All @@ -39,7 +38,6 @@ import {
SsoComponent,
TwoFactorTimeoutIcon,
} from "@bitwarden/auth/angular";
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";
import {
NewDeviceVerificationNoticePageOneComponent,
NewDeviceVerificationNoticePageTwoComponent,
Expand Down Expand Up @@ -329,7 +327,7 @@ const routes: Routes = [
children: [
{
path: "signup",
canActivate: [canAccessFeature(FeatureFlag.EmailVerification), unauthGuardFn()],
canActivate: [unauthGuardFn()],
data: {
pageIcon: RegistrationUserAddIcon,
pageTitle: {
Expand All @@ -353,7 +351,7 @@ const routes: Routes = [
},
{
path: "finish-signup",
canActivate: [canAccessFeature(FeatureFlag.EmailVerification), unauthGuardFn()],
canActivate: [unauthGuardFn()],
data: {
pageIcon: RegistrationLockAltIcon,
} satisfies AnonLayoutWrapperData,
Expand Down Expand Up @@ -383,7 +381,6 @@ const routes: Routes = [
},
{
path: "set-password-jit",
canActivate: [canAccessFeature(FeatureFlag.EmailVerification)],
component: SetPasswordJitComponent,
data: {
pageTitle: {
Expand Down
4 changes: 2 additions & 2 deletions apps/desktop/src/auth/login/login-v1.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<form
id="login-page"
#form
(ngSubmit)="submit()"
(ngSubmit)="submitLogin()"
rr-bw marked this conversation as resolved.
Show resolved Hide resolved
[appApiAction]="formPromise"
[formGroup]="formGroup"
attr.aria-hidden="{{ showingModal }}"
Expand Down Expand Up @@ -50,7 +50,7 @@
</div>
<div class="sub-options">
<p class="no-margin">{{ "newAroundHere" | i18n }}</p>
<button type="button" class="text text-primary" [routerLink]="registerRoute$ | async">
<button type="button" class="text text-primary" routerLink="/signup">
{{ "createAccount" | i18n }}
</button>
</div>
Expand Down
11 changes: 3 additions & 8 deletions apps/desktop/src/auth/login/login-v1.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@ import { ModalService } from "@bitwarden/angular/services/modal.service";
import {
LoginStrategyServiceAbstraction,
LoginEmailServiceAbstraction,
RegisterRouteService,
} from "@bitwarden/auth/common";
import { DevicesApiServiceAbstraction } from "@bitwarden/common/auth/abstractions/devices-api.service.abstraction";
import { SsoLoginServiceAbstraction } from "@bitwarden/common/auth/abstractions/sso-login.service.abstraction";
import { WebAuthnLoginServiceAbstraction } from "@bitwarden/common/auth/abstractions/webauthn/webauthn-login.service.abstraction";
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";
import { AppIdService } from "@bitwarden/common/platform/abstractions/app-id.service";
import { BroadcasterService } from "@bitwarden/common/platform/abstractions/broadcaster.service";
Expand Down Expand Up @@ -77,8 +75,6 @@ export class LoginComponentV1 extends BaseLoginComponent implements OnInit, OnDe
route: ActivatedRoute,
loginEmailService: LoginEmailServiceAbstraction,
ssoLoginService: SsoLoginServiceAbstraction,
webAuthnLoginService: WebAuthnLoginServiceAbstraction,
registerRouteService: RegisterRouteService,
toastService: ToastService,
private configService: ConfigService,
) {
Expand All @@ -100,8 +96,6 @@ export class LoginComponentV1 extends BaseLoginComponent implements OnInit, OnDe
route,
loginEmailService,
ssoLoginService,
webAuthnLoginService,
registerRouteService,
toastService,
);
this.onSuccessfulLogin = () => {
Expand Down Expand Up @@ -210,7 +204,7 @@ export class LoginComponentV1 extends BaseLoginComponent implements OnInit, OnDe
return;
}

await super.submit();
await super.submitLogin();
if (this.captchaSiteKey) {
const content = document.getElementById("content") as HTMLDivElement;
content.setAttribute("style", "width:335px");
Expand All @@ -228,7 +222,7 @@ export class LoginComponentV1 extends BaseLoginComponent implements OnInit, OnDe
}

// Save off email for SSO
await this.ssoLoginService.setSsoEmail(this.formGroup.value.email);
await this.ssoLoginService.setSsoEmail(this.formGroup.controls.email.value);

// Generate necessary sso params
const passwordOptions: any = {
Expand All @@ -247,6 +241,7 @@ export class LoginComponentV1 extends BaseLoginComponent implements OnInit, OnDe
// Save sso params
await this.ssoLoginService.setSsoState(state);
await this.ssoLoginService.setCodeVerifier(ssoCodeVerifier);

try {
await ipc.platform.localhostCallbackService.openSsoPrompt(codeChallenge, state);
} catch (err) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// @ts-strict-ignore
import { Component, inject } from "@angular/core";
import { Params } from "@angular/router";
import { firstValueFrom } from "rxjs";

import { PolicyApiServiceAbstraction } from "@bitwarden/common/admin-console/abstractions/policy/policy-api.service.abstraction";
import { OrganizationSponsorshipResponse } from "@bitwarden/common/admin-console/models/response/organization-sponsorship.response";
Expand Down Expand Up @@ -39,31 +38,19 @@ export class AcceptFamilySponsorshipComponent extends BaseAcceptComponent {
if (!qParams.register) {
await this.router.navigate(["/login"], { queryParams: { email: qParams.email } });
} else {
// TODO: update logic when email verification flag is removed
let queryParams: Params;
let registerRoute = await firstValueFrom(this.registerRoute$);
if (registerRoute === "/register") {
queryParams = {
email: qParams.email,
};
} else if (registerRoute === "/signup") {
// We have to override the base component route as we don't need users to
// complete email verification if they are coming directly an emailed invite.
// We have to override the base component route as we don't need users to
// complete email verification if they are coming directly an emailed invite.
rr-bw marked this conversation as resolved.
Show resolved Hide resolved

// TODO: in the future, to allow users to enter a name, consider sending all invite users to
// start registration page with prefilled email and a named token to be passed directly
// along to the finish-signup page without requiring email verification as
// we can treat the existence of the token as a form of email verification.
// TODO: in the future, to allow users to enter a name, consider sending all invite users to
// start registration page with prefilled email and a named token to be passed directly
// along to the finish-signup page without requiring email verification as
// we can treat the existence of the token as a form of email verification.

registerRoute = "/finish-signup";
queryParams = {
await this.router.navigate(["/finish-signup"], {
queryParams: {
email: qParams.email,
orgSponsoredFreeFamilyPlanToken: qParams.token,
};
}

await this.router.navigate([registerRoute], {
queryParams: queryParams,
},
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,18 @@ export class FamiliesForEnterpriseSetupComponent implements OnInit, OnDestroy {
loading = true;
badToken = false;

token: string;
existingFamilyOrganizations: Organization[];
existingFamilyOrganizations$: Observable<Organization[]>;
token!: string;
existingFamilyOrganizations$!: Observable<Organization[]>;

showNewOrganization = false;
_organizationPlansComponent: OrganizationPlansComponent;
preValidateSponsorshipResponse: PreValidateSponsorshipResponse;
preValidateSponsorshipResponse!: PreValidateSponsorshipResponse;
_selectedFamilyOrganizationId = "";

private _destroy = new Subject<void>();
formGroup = this.formBuilder.group({
selectedFamilyOrganizationId: ["", Validators.required],
});

constructor(
private router: Router,
private platformUtilsService: PlatformUtilsService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
// @ts-strict-ignore
import { Component } from "@angular/core";
import { ActivatedRoute, Params, Router } from "@angular/router";
import { firstValueFrom } from "rxjs";

import { RegisterRouteService } from "@bitwarden/auth/common";
import { AuthService } from "@bitwarden/common/auth/abstractions/auth.service";
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
Expand Down Expand Up @@ -34,10 +32,9 @@ export class AcceptEmergencyComponent extends BaseAcceptComponent {
i18nService: I18nService,
route: ActivatedRoute,
authService: AuthService,
registerRouteService: RegisterRouteService,
private emergencyAccessService: EmergencyAccessService,
) {
super(router, platformUtilsService, i18nService, route, authService, registerRouteService);
super(router, platformUtilsService, i18nService, route, authService);
}

async authedHandler(qParams: Params): Promise<void> {
Expand Down Expand Up @@ -71,25 +68,12 @@ export class AcceptEmergencyComponent extends BaseAcceptComponent {
}

async register() {
let queryParams: Params;
let registerRoute = await firstValueFrom(this.registerRoute$);
if (registerRoute === "/register") {
queryParams = {
email: this.email,
};
} else if (registerRoute === "/signup") {
// We have to override the base component route as we don't need users to
// complete email verification if they are coming directly an emailed invite.
registerRoute = "/finish-signup";
queryParams = {
await this.router.navigate(["/signup"], {
rr-bw marked this conversation as resolved.
Show resolved Hide resolved
queryParams: {
email: this.email,
acceptEmergencyAccessInviteToken: this.acceptEmergencyAccessInviteToken,
emergencyAccessId: this.emergencyAccessId,
};
}

await this.router.navigate([registerRoute], {
queryParams: queryParams,
},
});
}
}
Loading
Loading