mirror of
https://github.com/bitwarden/browser
synced 2025-12-10 05:13:29 +00:00
feat(marketing-initiated-premium): Auth [PM-27542] Write fromMarketing value to state (#17470)
This commit is contained in:
@@ -5,6 +5,7 @@ import { Component, OnDestroy, OnInit } from "@angular/core";
|
|||||||
import { ActivatedRoute, Params, Router, RouterModule } from "@angular/router";
|
import { ActivatedRoute, Params, Router, RouterModule } from "@angular/router";
|
||||||
import { Subject, firstValueFrom } from "rxjs";
|
import { Subject, firstValueFrom } from "rxjs";
|
||||||
|
|
||||||
|
import { PremiumInterestStateService } from "@bitwarden/angular/billing/services/premium-interest/premium-interest-state.service.abstraction";
|
||||||
import { JslibModule } from "@bitwarden/angular/jslib.module";
|
import { JslibModule } from "@bitwarden/angular/jslib.module";
|
||||||
import { MasterPasswordPolicyOptions } from "@bitwarden/common/admin-console/models/domain/master-password-policy-options";
|
import { MasterPasswordPolicyOptions } from "@bitwarden/common/admin-console/models/domain/master-password-policy-options";
|
||||||
import { AccountApiService } from "@bitwarden/common/auth/abstractions/account-api.service";
|
import { AccountApiService } from "@bitwarden/common/auth/abstractions/account-api.service";
|
||||||
@@ -31,6 +32,12 @@ import { PasswordInputResult } from "../../input-password/password-input-result"
|
|||||||
|
|
||||||
import { RegistrationFinishService } from "./registration-finish.service";
|
import { RegistrationFinishService } from "./registration-finish.service";
|
||||||
|
|
||||||
|
const MarketingInitiative = Object.freeze({
|
||||||
|
Premium: "premium",
|
||||||
|
} as const);
|
||||||
|
|
||||||
|
type MarketingInitiative = (typeof MarketingInitiative)[keyof typeof MarketingInitiative];
|
||||||
|
|
||||||
// FIXME(https://bitwarden.atlassian.net/browse/CL-764): Migrate to OnPush
|
// FIXME(https://bitwarden.atlassian.net/browse/CL-764): Migrate to OnPush
|
||||||
// eslint-disable-next-line @angular-eslint/prefer-on-push-component-change-detection
|
// eslint-disable-next-line @angular-eslint/prefer-on-push-component-change-detection
|
||||||
@Component({
|
@Component({
|
||||||
@@ -46,6 +53,12 @@ export class RegistrationFinishComponent implements OnInit, OnDestroy {
|
|||||||
submitting = false;
|
submitting = false;
|
||||||
email: string;
|
email: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates that the user is coming from a marketing page designed to streamline
|
||||||
|
* users who intend to setup a premium subscription after registration.
|
||||||
|
*/
|
||||||
|
premiumInterest = false;
|
||||||
|
|
||||||
// Note: this token is the email verification token. When it is supplied as a query param,
|
// Note: this token is the email verification token. When it is supplied as a query param,
|
||||||
// it either comes from the email verification email or, if email verification is disabled server side
|
// it either comes from the email verification email or, if email verification is disabled server side
|
||||||
// via global settings, it comes directly from the registration-start component directly.
|
// via global settings, it comes directly from the registration-start component directly.
|
||||||
@@ -79,6 +92,7 @@ export class RegistrationFinishComponent implements OnInit, OnDestroy {
|
|||||||
private logService: LogService,
|
private logService: LogService,
|
||||||
private anonLayoutWrapperDataService: AnonLayoutWrapperDataService,
|
private anonLayoutWrapperDataService: AnonLayoutWrapperDataService,
|
||||||
private loginSuccessHandlerService: LoginSuccessHandlerService,
|
private loginSuccessHandlerService: LoginSuccessHandlerService,
|
||||||
|
private premiumInterestStateService: PremiumInterestStateService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
async ngOnInit() {
|
async ngOnInit() {
|
||||||
@@ -126,6 +140,10 @@ export class RegistrationFinishComponent implements OnInit, OnDestroy {
|
|||||||
this.providerInviteToken = qParams.providerInviteToken;
|
this.providerInviteToken = qParams.providerInviteToken;
|
||||||
this.providerUserId = qParams.providerUserId;
|
this.providerUserId = qParams.providerUserId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (qParams.fromMarketing != null && qParams.fromMarketing === MarketingInitiative.Premium) {
|
||||||
|
this.premiumInterest = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async initOrgInviteFlowIfPresent(): Promise<boolean> {
|
private async initOrgInviteFlowIfPresent(): Promise<boolean> {
|
||||||
@@ -190,6 +208,13 @@ export class RegistrationFinishComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
await this.loginSuccessHandlerService.run(authenticationResult.userId);
|
await this.loginSuccessHandlerService.run(authenticationResult.userId);
|
||||||
|
|
||||||
|
if (this.premiumInterest) {
|
||||||
|
await this.premiumInterestStateService.setPremiumInterest(
|
||||||
|
authenticationResult.userId,
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
await this.router.navigate(["/vault"]);
|
await this.router.navigate(["/vault"]);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// If login errors, redirect to login page per product. Don't show error
|
// If login errors, redirect to login page per product. Don't show error
|
||||||
|
|||||||
Reference in New Issue
Block a user