This commit is contained in:
Manav Rathi 2024-05-26 18:13:02 +05:30
parent 452872156a
commit 14cf59c1e5
No known key found for this signature in database
2 changed files with 11 additions and 6 deletions

View file

@ -1,4 +1,5 @@
import log from "@/next/log"; import log from "@/next/log";
import { appNameToAppNameOld } from "@ente/shared/apps/constants";
import type { PageProps } from "@ente/shared/apps/types"; import type { PageProps } from "@ente/shared/apps/types";
import { VerticallyCentered } from "@ente/shared/components/Container"; import { VerticallyCentered } from "@ente/shared/components/Container";
import EnteSpinner from "@ente/shared/components/EnteSpinner"; import EnteSpinner from "@ente/shared/components/EnteSpinner";
@ -18,7 +19,6 @@ import React, { useEffect, useState } from "react";
import { getSRPAttributes } from "../api/srp"; import { getSRPAttributes } from "../api/srp";
import { sendOtt } from "../api/user"; import { sendOtt } from "../api/user";
import { PAGES } from "../constants/pages"; import { PAGES } from "../constants/pages";
import { appNameToAppNameOld } from "@ente/shared/apps/constants";
const Page: React.FC<PageProps> = ({ appContext }) => { const Page: React.FC<PageProps> = ({ appContext }) => {
const { appName, showNavBar } = appContext; const { appName, showNavBar } = appContext;

View file

@ -2,7 +2,7 @@ import log from "@/next/log";
import { ensure } from "@/utils/ensure"; import { ensure } from "@/utils/ensure";
import { sendOtt } from "@ente/accounts/api/user"; import { sendOtt } from "@ente/accounts/api/user";
import { PAGES } from "@ente/accounts/constants/pages"; import { PAGES } from "@ente/accounts/constants/pages";
import { APP_HOMES } from "@ente/shared/apps/constants"; import { APP_HOMES, appNameToAppNameOld } from "@ente/shared/apps/constants";
import type { PageProps } from "@ente/shared/apps/types"; import type { PageProps } from "@ente/shared/apps/types";
import { VerticallyCentered } from "@ente/shared/components/Container"; import { VerticallyCentered } from "@ente/shared/components/Container";
import FormPaper from "@ente/shared/components/Form/FormPaper"; import FormPaper from "@ente/shared/components/Form/FormPaper";
@ -29,13 +29,16 @@ const bip39 = require("bip39");
// mobile client library only supports english. // mobile client library only supports english.
bip39.setDefaultWordlist("english"); bip39.setDefaultWordlist("english");
export default function Recover({ appContext, appName }: PageProps) { const Page: React.FC<PageProps> = ({ appContext }) => {
const [keyAttributes, setKeyAttributes] = useState< const [keyAttributes, setKeyAttributes] = useState<
KeyAttributes | undefined KeyAttributes | undefined
>(); >();
const router = useRouter(); const router = useRouter();
const appNameOld = appNameToAppNameOld(appContext.appName);
useEffect(() => { useEffect(() => {
const user: User = getData(LS_KEYS.USER); const user: User = getData(LS_KEYS.USER);
const keyAttributes: KeyAttributes = getData(LS_KEYS.KEY_ATTRIBUTES); const keyAttributes: KeyAttributes = getData(LS_KEYS.KEY_ATTRIBUTES);
@ -45,7 +48,7 @@ export default function Recover({ appContext, appName }: PageProps) {
return; return;
} }
if (!user?.encryptedToken && !user?.token) { if (!user?.encryptedToken && !user?.token) {
sendOtt(appName, user.email); sendOtt(appNameOld, user.email);
InMemoryStore.set(MS_KEYS.REDIRECT_URL, PAGES.RECOVER); InMemoryStore.set(MS_KEYS.REDIRECT_URL, PAGES.RECOVER);
router.push(PAGES.VERIFY); router.push(PAGES.VERIFY);
return; return;
@ -54,7 +57,7 @@ export default function Recover({ appContext, appName }: PageProps) {
router.push(PAGES.GENERATE); router.push(PAGES.GENERATE);
} else if (key) { } else if (key) {
// TODO: Refactor the type of APP_HOMES to not require the ?? // TODO: Refactor the type of APP_HOMES to not require the ??
router.push(APP_HOMES.get(appName) ?? "/"); router.push(APP_HOMES.get(appNameOld) ?? "/");
} else { } else {
setKeyAttributes(keyAttributes); setKeyAttributes(keyAttributes);
} }
@ -127,4 +130,6 @@ export default function Recover({ appContext, appName }: PageProps) {
</FormPaper> </FormPaper>
</VerticallyCentered> </VerticallyCentered>
); );
} };
export default Page;