Start redirecting new users to the welcome screen
Here, "new users" are defined as those who are in the US, have not yet run a data broker scan, and did not create their Monitor account before the release of data broker scanning, as determined by the date set in the `BROKER_SCAN_RELEASE_DATE` environment variable.
This commit is contained in:
Родитель
d30bd410a8
Коммит
61e1dbcbfe
|
@ -137,6 +137,11 @@ FXA_SUBSCRIPTIONS_URL=https://accounts.stage.mozaws.net/subscriptions
|
|||
PREMIUM_PRODUCT_ID=prod_NErZh679W62lai
|
||||
PREMIUM_PLAN_ID_MONTHLY_US=price_1MUNq0Kb9q6OnNsL4BoJgepf
|
||||
PREMIUM_PLAN_ID_YEARLY_US=
|
||||
# This date is used to direct users who signed up after data broker scanning
|
||||
# was released to the welcome flow. Users who had signed up before and thus
|
||||
# have seen data breach results before, will be able to see their known breaches
|
||||
# first:
|
||||
BROKER_SCAN_RELEASE_DATE=2023-12-05
|
||||
|
||||
MONTHLY_SUBSCRIBERS_QUOTA=
|
||||
MONTHLY_SCANS_QUOTA=
|
||||
|
|
|
@ -23,6 +23,7 @@ import {
|
|||
import getPremiumSubscriptionUrl from "../../../../../functions/server/getPremiumSubscriptionUrl";
|
||||
import { refreshStoredScanResults } from "../../../../../functions/server/refreshStoredScanResults";
|
||||
import { getEnabledFeatureFlags } from "../../../../../../db/tables/featureFlags";
|
||||
import { parseIso8601Datetime } from "../../../../../../utils/parse";
|
||||
export default async function DashboardPage() {
|
||||
const session = await getServerSession(authOptions);
|
||||
if (!session?.user?.subscriber?.id) {
|
||||
|
@ -34,9 +35,24 @@ export default async function DashboardPage() {
|
|||
|
||||
const result = await getOnerepProfileId(session.user.subscriber.id);
|
||||
const profileId = result[0]["onerep_profile_id"] as number;
|
||||
const brokerScanReleaseDateParts = (
|
||||
process.env.BROKER_SCAN_RELEASE_DATE ?? ""
|
||||
).split("-");
|
||||
if (brokerScanReleaseDateParts[0] === "") {
|
||||
brokerScanReleaseDateParts[0] = "2023";
|
||||
}
|
||||
const brokerScanReleaseDate = new Date(
|
||||
Date.UTC(
|
||||
Number.parseInt(brokerScanReleaseDateParts[0], 10),
|
||||
Number.parseInt(brokerScanReleaseDateParts[1] ?? "12", 10) - 1,
|
||||
Number.parseInt(brokerScanReleaseDateParts[2] ?? "05", 10),
|
||||
),
|
||||
);
|
||||
if (
|
||||
!profileId &&
|
||||
canSubscribeToPremium({ user: session?.user, countryCode: countryCode })
|
||||
canSubscribeToPremium({ user: session?.user, countryCode: countryCode }) &&
|
||||
(parseIso8601Datetime(session.user.subscriber.created_at)?.getTime() ?? 0) >
|
||||
brokerScanReleaseDate.getTime()
|
||||
) {
|
||||
return redirect("/redesign/user/welcome/");
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ import { getTemplate } from "../../../views/emails/email2022.js";
|
|||
import { signupReportEmailPartial } from "../../../views/emails/emailSignupReport.js";
|
||||
import { getL10n } from "../../functions/server/l10n";
|
||||
import { OAuthConfig } from "next-auth/providers/oauth.js";
|
||||
import { SerializedSubscriber } from "../../../next-auth.js";
|
||||
|
||||
const log = mozlog("controllers.auth");
|
||||
|
||||
|
@ -112,7 +113,10 @@ export const authOptions: AuthOptions = {
|
|||
account.refresh_token,
|
||||
JSON.stringify(profile),
|
||||
);
|
||||
token.subscriber = verifiedSubscriber;
|
||||
// The date fields of `verifiedSubscriber` get converted to an ISO 8601
|
||||
// date string when serialised in the token, hence the type assertion:
|
||||
token.subscriber =
|
||||
verifiedSubscriber as unknown as SerializedSubscriber;
|
||||
|
||||
const allBreaches = await getBreaches();
|
||||
const unsafeBreachesForEmail = await getBreachesForEmail(
|
||||
|
|
|
@ -4,6 +4,11 @@
|
|||
|
||||
import { DefaultSession } from "next-auth";
|
||||
import { SubscriberRow } from "knex/types/tables";
|
||||
import { ISO8601DateString } from "./utils/parse";
|
||||
|
||||
export type SerializedSubscriber = Omit<SubscriberRow, "created_at"> & {
|
||||
created_at: ISO8601DateString;
|
||||
};
|
||||
|
||||
declare module "next-auth" {
|
||||
/** The OAuth profile extracted from Firefox Accounts */
|
||||
|
@ -48,7 +53,7 @@ declare module "next-auth" {
|
|||
avatarDefault: boolean;
|
||||
subscriptions: Array<string>;
|
||||
};
|
||||
subscriber?: SubscriberRow;
|
||||
subscriber?: SerializedSubscriber;
|
||||
} & DefaultSession["user"] & { email: string };
|
||||
}
|
||||
}
|
||||
|
@ -66,6 +71,6 @@ declare module "next-auth/jwt" {
|
|||
avatarDefault: boolean;
|
||||
subscriptions: Array<string>;
|
||||
};
|
||||
subscriber?: SubscriberRow;
|
||||
subscriber?: SerializedSubscriber;
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче