1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-13 06:43:35 +00:00

[SG-576] Added reference data to trial initiation (#3312)

* Added reference data to trial initiation

* refactored to use private methods

* refactored to use private methods
This commit is contained in:
Gbubemi Smith
2022-08-19 17:10:23 +01:00
committed by GitHub
parent 4c099aca46
commit d8cb543645
2 changed files with 42 additions and 2 deletions

View File

@@ -1,11 +1,12 @@
<div *ngIf="accountCreateOnly" class=""> <div *ngIf="accountCreateOnly" class="">
<h1 class="tw-mt-12 tw-text-center tw-text-xl" *ngIf="!layout">{{ "createAccount" | i18n }}</h1> <h1 class="tw-mt-12 tw-text-center tw-text-xl">{{ "createAccount" | i18n }}</h1>
<div <div
class="tw-min-w-xl tw-m-auto tw-max-w-xl tw-rounded tw-border tw-border-solid tw-border-secondary-300 tw-bg-background tw-p-8" class="tw-min-w-xl tw-m-auto tw-max-w-xl tw-rounded tw-border tw-border-solid tw-border-secondary-300 tw-bg-background tw-p-8"
> >
<app-register-form <app-register-form
[queryParamEmail]="email" [queryParamEmail]="email"
[enforcedPolicyOptions]="enforcedPolicyOptions" [enforcedPolicyOptions]="enforcedPolicyOptions"
[referenceDataValue]="referenceData"
></app-register-form> ></app-register-form>
</div> </div>
</div> </div>
@@ -53,6 +54,7 @@
<app-register-form <app-register-form
[isInTrialFlow]="true" [isInTrialFlow]="true"
(createdAccount)="createdAccount($event)" (createdAccount)="createdAccount($event)"
[referenceDataValue]="referenceData"
></app-register-form> ></app-register-form>
</app-vertical-step> </app-vertical-step>
<app-vertical-step label="Organization Information" [subLabel]="orgInfoSubLabel"> <app-vertical-step label="Organization Information" [subLabel]="orgInfoSubLabel">

View File

@@ -15,7 +15,9 @@ import { ProductType } from "@bitwarden/common/enums/productType";
import { PolicyData } from "@bitwarden/common/models/data/policyData"; import { PolicyData } from "@bitwarden/common/models/data/policyData";
import { MasterPasswordPolicyOptions } from "@bitwarden/common/models/domain/masterPasswordPolicyOptions"; import { MasterPasswordPolicyOptions } from "@bitwarden/common/models/domain/masterPasswordPolicyOptions";
import { Policy } from "@bitwarden/common/models/domain/policy"; 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"; import { VerticalStepperComponent } from "./vertical-stepper/vertical-stepper.component";
@Component({ @Component({
@@ -36,6 +38,7 @@ export class TrialInitiationComponent implements OnInit {
policies: Policy[]; policies: Policy[];
enforcedPolicyOptions: MasterPasswordPolicyOptions; enforcedPolicyOptions: MasterPasswordPolicyOptions;
validOrgs: string[] = ["teams", "enterprise", "families"]; validOrgs: string[] = ["teams", "enterprise", "families"];
referenceData: ReferenceEventRequest;
@ViewChild("stepper", { static: false }) verticalStepper: VerticalStepperComponent; @ViewChild("stepper", { static: false }) verticalStepper: VerticalStepperComponent;
orgInfoFormGroup = this.formBuilder.group({ orgInfoFormGroup = this.formBuilder.group({
@@ -43,6 +46,22 @@ export class TrialInitiationComponent implements OnInit {
email: [""], 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( constructor(
private route: ActivatedRoute, private route: ActivatedRoute,
protected router: Router, protected router: Router,
@@ -52,15 +71,19 @@ export class TrialInitiationComponent implements OnInit {
private logService: LogService, private logService: LogService,
private policyApiService: PolicyApiServiceAbstraction, private policyApiService: PolicyApiServiceAbstraction,
private policyService: PolicyService, private policyService: PolicyService,
private i18nService: I18nService private i18nService: I18nService,
private routerService: RouterService
) {} ) {}
async ngOnInit(): Promise<void> { async ngOnInit(): Promise<void> {
this.route.queryParams.pipe(first()).subscribe((qParams) => { this.route.queryParams.pipe(first()).subscribe((qParams) => {
this.referenceData = new ReferenceEventRequest();
if (qParams.email != null && qParams.email.indexOf("@") > -1) { if (qParams.email != null && qParams.email.indexOf("@") > -1) {
this.email = qParams.email; this.email = qParams.email;
} }
this.referenceDataId = qParams.reference;
if (!qParams.org) { if (!qParams.org) {
return; return;
} }
@@ -75,6 +98,12 @@ export class TrialInitiationComponent implements OnInit {
this.org = "families"; 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.orgLabel = this.titleCasePipe.transform(this.org);
this.accountCreateOnly = false; this.accountCreateOnly = false;
@@ -153,4 +182,13 @@ export class TrialInitiationComponent implements OnInit {
previousStep() { previousStep() {
this.verticalStepper.previous(); 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());
}
}
} }