mirror of
https://github.com/bitwarden/browser
synced 2025-12-16 16:23:44 +00:00
Move Trial Initiation to register route (#3129)
This commit is contained in:
@@ -1,8 +1,19 @@
|
|||||||
<div
|
<div *ngIf="accountCreateOnly" class="">
|
||||||
|
<h1 class="tw-text-xl tw-text-center tw-mt-12" *ngIf="!layout">{{ "createAccount" | i18n }}</h1>
|
||||||
|
<div
|
||||||
|
class="tw-m-auto tw-rounded tw-border tw-border-solid tw-bg-background tw-border-secondary-300 tw-min-w-xl tw-max-w-xl tw-p-8"
|
||||||
|
>
|
||||||
|
<app-register-form
|
||||||
|
[queryParamEmail]="email"
|
||||||
|
[enforcedPolicyOptions]="enforcedPolicyOptions"
|
||||||
|
></app-register-form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div *ngIf="!accountCreateOnly">
|
||||||
|
<div
|
||||||
class="tw-bg-background-alt2 tw-h-96 tw--mt-48 tw-absolute tw--skew-y-3 tw-w-full tw--z-10"
|
class="tw-bg-background-alt2 tw-h-96 tw--mt-48 tw-absolute tw--skew-y-3 tw-w-full tw--z-10"
|
||||||
></div>
|
></div>
|
||||||
|
<div class="tw-flex tw-max-w-screen-xl tw-min-w-4xl tw-mx-auto tw-px-4">
|
||||||
<div class="tw-flex tw-max-w-screen-xl tw-min-w-4xl tw-mx-auto tw-px-4">
|
|
||||||
<div class="tw-w-1/2">
|
<div class="tw-w-1/2">
|
||||||
<img
|
<img
|
||||||
alt="Bitwarden"
|
alt="Bitwarden"
|
||||||
@@ -61,4 +72,5 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -5,6 +5,15 @@ import { FormBuilder, Validators } from "@angular/forms";
|
|||||||
import { ActivatedRoute } from "@angular/router";
|
import { ActivatedRoute } from "@angular/router";
|
||||||
import { first } from "rxjs";
|
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";
|
import { VerticalStepperComponent } from "../vertical-stepper/vertical-stepper.component";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@@ -15,6 +24,9 @@ export class TrialInitiationComponent implements OnInit {
|
|||||||
email = "";
|
email = "";
|
||||||
org = "teams";
|
org = "teams";
|
||||||
orgInfoSubLabel = "";
|
orgInfoSubLabel = "";
|
||||||
|
accountCreateOnly = true;
|
||||||
|
policies: Policy[];
|
||||||
|
enforcedPolicyOptions: MasterPasswordPolicyOptions;
|
||||||
@ViewChild("stepper", { static: true }) verticalStepper: VerticalStepperComponent;
|
@ViewChild("stepper", { static: true }) verticalStepper: VerticalStepperComponent;
|
||||||
|
|
||||||
orgInfoFormGroup = this.formBuilder.group({
|
orgInfoFormGroup = this.formBuilder.group({
|
||||||
@@ -29,18 +41,48 @@ export class TrialInitiationComponent implements OnInit {
|
|||||||
constructor(
|
constructor(
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
private formBuilder: FormBuilder,
|
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<void> {
|
||||||
this.route.queryParams.pipe(first()).subscribe((qParams) => {
|
this.route.queryParams.pipe(first()).subscribe((qParams) => {
|
||||||
if (qParams.email != null && qParams.email.indexOf("@") > -1) {
|
if (qParams.email != null && qParams.email.indexOf("@") > -1) {
|
||||||
this.email = qParams.email;
|
this.email = qParams.email;
|
||||||
}
|
}
|
||||||
if (qParams.org) {
|
if (qParams.org) {
|
||||||
this.org = 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) {
|
stepSelectionChange(event: StepperSelectionEvent) {
|
||||||
|
|||||||
@@ -63,16 +63,10 @@ const routes: Routes = [
|
|||||||
{ path: "2fa", component: TwoFactorComponent, canActivate: [UnauthGuard] },
|
{ path: "2fa", component: TwoFactorComponent, canActivate: [UnauthGuard] },
|
||||||
{
|
{
|
||||||
path: "register",
|
path: "register",
|
||||||
component: RegisterComponent,
|
component: flagEnabled("showTrial") ? TrialInitiationComponent : RegisterComponent,
|
||||||
canActivate: [UnauthGuard],
|
canActivate: [UnauthGuard],
|
||||||
data: { titleId: "createAccount" },
|
data: { titleId: "createAccount" },
|
||||||
},
|
},
|
||||||
buildFlaggedRoute("showTrial", {
|
|
||||||
path: "trial",
|
|
||||||
component: TrialInitiationComponent,
|
|
||||||
canActivate: [UnauthGuard],
|
|
||||||
data: { titleId: "startTrial" },
|
|
||||||
}),
|
|
||||||
{
|
{
|
||||||
path: "sso",
|
path: "sso",
|
||||||
component: SsoComponent,
|
component: SsoComponent,
|
||||||
|
|||||||
Reference in New Issue
Block a user