From 2ddba6d2c3c0e847055b3b4744c57e883874dc94 Mon Sep 17 00:00:00 2001 From: Robyn MacCallum Date: Tue, 19 Jul 2022 11:52:18 -0400 Subject: [PATCH] Move Trial Initiation to register route (#3129) --- .../trial-initiation.component.html | 128 ++++++++++-------- .../trial-initiation.component.ts | 46 ++++++- apps/web/src/app/oss-routing.module.ts | 8 +- 3 files changed, 115 insertions(+), 67 deletions(-) diff --git a/apps/web/src/app/modules/trial-initiation/trial-initiation.component.html b/apps/web/src/app/modules/trial-initiation/trial-initiation.component.html index b0c98486dc..25037ce855 100644 --- a/apps/web/src/app/modules/trial-initiation/trial-initiation.component.html +++ b/apps/web/src/app/modules/trial-initiation/trial-initiation.component.html @@ -1,63 +1,75 @@ -
- -
-
- Bitwarden - -
- - - - - - -
+
+

{{ "createAccount" | i18n }}

+
+
-
-
-
-
-

- Start your 7-Day free trial of Bitwarden for {{ org }} -

+
+
+
+
+
+ Bitwarden + +
+ + + + + + +
+
+
+
+
+
+

+ Start your 7-Day free trial of Bitwarden for {{ org }} +

+
+ + + + + + + + + + +

This is content of "Step 3"

+ + +
+ + +

This is any content of "Step 4"

+ +
+
- - - - - - - - - - -

This is content of "Step 3"

- - -
- - -

This is any content of "Step 4"

- -
-
diff --git a/apps/web/src/app/modules/trial-initiation/trial-initiation.component.ts b/apps/web/src/app/modules/trial-initiation/trial-initiation.component.ts index 0e6772ff3d..188cf857cb 100644 --- a/apps/web/src/app/modules/trial-initiation/trial-initiation.component.ts +++ b/apps/web/src/app/modules/trial-initiation/trial-initiation.component.ts @@ -5,6 +5,15 @@ import { FormBuilder, Validators } from "@angular/forms"; import { ActivatedRoute } from "@angular/router"; import { first } from "rxjs"; +import { ApiService } from "@bitwarden/common/abstractions/api.service"; +import { I18nService } from "@bitwarden/common/abstractions/i18n.service"; +import { LogService } from "@bitwarden/common/abstractions/log.service"; +import { PolicyService } from "@bitwarden/common/abstractions/policy.service"; +import { StateService } from "@bitwarden/common/abstractions/state.service"; +import { PolicyData } from "@bitwarden/common/models/data/policyData"; +import { MasterPasswordPolicyOptions } from "@bitwarden/common/models/domain/masterPasswordPolicyOptions"; +import { Policy } from "@bitwarden/common/models/domain/policy"; + import { VerticalStepperComponent } from "../vertical-stepper/vertical-stepper.component"; @Component({ @@ -15,6 +24,9 @@ export class TrialInitiationComponent implements OnInit { email = ""; org = "teams"; orgInfoSubLabel = ""; + accountCreateOnly = true; + policies: Policy[]; + enforcedPolicyOptions: MasterPasswordPolicyOptions; @ViewChild("stepper", { static: true }) verticalStepper: VerticalStepperComponent; orgInfoFormGroup = this.formBuilder.group({ @@ -29,18 +41,48 @@ export class TrialInitiationComponent implements OnInit { constructor( private route: ActivatedRoute, private formBuilder: FormBuilder, - private titleCasePipe: TitleCasePipe + private titleCasePipe: TitleCasePipe, + private stateService: StateService, + private apiService: ApiService, + private logService: LogService, + private policyService: PolicyService, + private i18nService: I18nService ) {} - ngOnInit(): void { + async ngOnInit(): Promise { this.route.queryParams.pipe(first()).subscribe((qParams) => { if (qParams.email != null && qParams.email.indexOf("@") > -1) { this.email = qParams.email; } if (qParams.org) { this.org = qParams.org; + this.accountCreateOnly = false; } }); + + const invite = await this.stateService.getOrganizationInvitation(); + if (invite != null) { + try { + const policies = await this.apiService.getPoliciesByToken( + invite.organizationId, + invite.token, + invite.email, + invite.organizationUserId + ); + if (policies.data != null) { + const policiesData = policies.data.map((p) => new PolicyData(p)); + this.policies = policiesData.map((p) => new Policy(p)); + } + } catch (e) { + this.logService.error(e); + } + } + + if (this.policies != null) { + this.enforcedPolicyOptions = await this.policyService.getMasterPasswordPolicyOptions( + this.policies + ); + } } stepSelectionChange(event: StepperSelectionEvent) { diff --git a/apps/web/src/app/oss-routing.module.ts b/apps/web/src/app/oss-routing.module.ts index 76501a16f4..f2cde10f2e 100644 --- a/apps/web/src/app/oss-routing.module.ts +++ b/apps/web/src/app/oss-routing.module.ts @@ -63,16 +63,10 @@ const routes: Routes = [ { path: "2fa", component: TwoFactorComponent, canActivate: [UnauthGuard] }, { path: "register", - component: RegisterComponent, + component: flagEnabled("showTrial") ? TrialInitiationComponent : RegisterComponent, canActivate: [UnauthGuard], data: { titleId: "createAccount" }, }, - buildFlaggedRoute("showTrial", { - path: "trial", - component: TrialInitiationComponent, - canActivate: [UnauthGuard], - data: { titleId: "startTrial" }, - }), { path: "sso", component: SsoComponent,