diff --git a/apps/web/src/app/accounts/trial-initiation/trial-initiation.component.html b/apps/web/src/app/accounts/trial-initiation/trial-initiation.component.html
index 9251923c3c4..db96ed92ffd 100644
--- a/apps/web/src/app/accounts/trial-initiation/trial-initiation.component.html
+++ b/apps/web/src/app/accounts/trial-initiation/trial-initiation.component.html
@@ -1,11 +1,12 @@
-
{{ "createAccount" | i18n }}
+
{{ "createAccount" | i18n }}
@@ -53,6 +54,7 @@
diff --git a/apps/web/src/app/accounts/trial-initiation/trial-initiation.component.ts b/apps/web/src/app/accounts/trial-initiation/trial-initiation.component.ts
index 8f20d1c7e9e..45f4815f477 100644
--- a/apps/web/src/app/accounts/trial-initiation/trial-initiation.component.ts
+++ b/apps/web/src/app/accounts/trial-initiation/trial-initiation.component.ts
@@ -15,7 +15,9 @@ import { ProductType } from "@bitwarden/common/enums/productType";
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 { ReferenceEventRequest } from "@bitwarden/common/models/request/referenceEventRequest";
+import { RouterService } from "./../../core/router.service";
import { VerticalStepperComponent } from "./vertical-stepper/vertical-stepper.component";
@Component({
@@ -36,6 +38,7 @@ export class TrialInitiationComponent implements OnInit {
policies: Policy[];
enforcedPolicyOptions: MasterPasswordPolicyOptions;
validOrgs: string[] = ["teams", "enterprise", "families"];
+ referenceData: ReferenceEventRequest;
@ViewChild("stepper", { static: false }) verticalStepper: VerticalStepperComponent;
orgInfoFormGroup = this.formBuilder.group({
@@ -43,6 +46,22 @@ export class TrialInitiationComponent implements OnInit {
email: [""],
});
+ private set referenceDataId(referenceId: string) {
+ if (referenceId != null) {
+ this.referenceData.id = referenceId;
+ } else {
+ this.referenceData.id = ("; " + document.cookie)
+ .split("; reference=")
+ .pop()
+ .split(";")
+ .shift();
+ }
+
+ if (this.referenceData.id === "") {
+ this.referenceData.id = null;
+ }
+ }
+
constructor(
private route: ActivatedRoute,
protected router: Router,
@@ -52,15 +71,19 @@ export class TrialInitiationComponent implements OnInit {
private logService: LogService,
private policyApiService: PolicyApiServiceAbstraction,
private policyService: PolicyService,
- private i18nService: I18nService
+ private i18nService: I18nService,
+ private routerService: RouterService
) {}
async ngOnInit(): Promise {
this.route.queryParams.pipe(first()).subscribe((qParams) => {
+ this.referenceData = new ReferenceEventRequest();
if (qParams.email != null && qParams.email.indexOf("@") > -1) {
this.email = qParams.email;
}
+ this.referenceDataId = qParams.reference;
+
if (!qParams.org) {
return;
}
@@ -75,6 +98,12 @@ export class TrialInitiationComponent implements OnInit {
this.org = "families";
}
+ this.referenceData.flow = qParams.org;
+
+ // Are they coming from an email for sponsoring a families organization
+ // After logging in redirect them to setup the families sponsorship
+ this.setupFamilySponsorship(qParams.sponsorshipToken);
+
this.orgLabel = this.titleCasePipe.transform(this.org);
this.accountCreateOnly = false;
@@ -153,4 +182,13 @@ export class TrialInitiationComponent implements OnInit {
previousStep() {
this.verticalStepper.previous();
}
+
+ private setupFamilySponsorship(sponsorshipToken: string) {
+ if (sponsorshipToken != null) {
+ const route = this.router.createUrlTree(["setup/families-for-enterprise"], {
+ queryParams: { plan: sponsorshipToken },
+ });
+ this.routerService.setPreviousUrl(route.toString());
+ }
+ }
}