mirror of
https://github.com/ente-io/ente.git
synced 2025-08-08 07:28:26 +00:00
type
This commit is contained in:
parent
b0ce1c971b
commit
1ff6a53131
@ -1,9 +1,8 @@
|
||||
import { TwoFactorType } from "@ente/accounts/constants/twofactor";
|
||||
import Page_ from "@ente/accounts/pages/two-factor/recover";
|
||||
import { useAppContext } from "../../_app";
|
||||
|
||||
const Page = () => (
|
||||
<Page_ appContext={useAppContext()} twoFactorType={TwoFactorType.PASSKEY} />
|
||||
<Page_ appContext={useAppContext()} twoFactorType="passkey" />
|
||||
);
|
||||
|
||||
export default Page;
|
||||
|
@ -1,6 +1,6 @@
|
||||
import Page_ from "@ente/accounts/pages/two-factor/recover";
|
||||
import { useAppContext } from "../_app";
|
||||
|
||||
const Page = () => <Page_ appContext={useAppContext()} />;
|
||||
const Page = () => <Page_ appContext={useAppContext()} twoFactorType="totp" />;
|
||||
|
||||
export default Page;
|
||||
|
@ -1,6 +1,6 @@
|
||||
import Page_ from "@ente/accounts/pages/two-factor/recover";
|
||||
import { useAppContext } from "../_app";
|
||||
|
||||
const Page = () => <Page_ appContext={useAppContext()} />;
|
||||
const Page = () => <Page_ appContext={useAppContext()} twoFactorType="totp" />;
|
||||
|
||||
export default Page;
|
||||
|
@ -1,6 +1,6 @@
|
||||
import Page_ from "@ente/accounts/pages/two-factor/recover";
|
||||
import { useAppContext } from "../_app";
|
||||
|
||||
const Page = () => <Page_ appContext={useAppContext()} />;
|
||||
const Page = () => <Page_ appContext={useAppContext()} twoFactorType="totp" />;
|
||||
|
||||
export default Page;
|
||||
|
@ -13,7 +13,6 @@ import { getEndpoint } from "@ente/shared/network/api";
|
||||
import { getToken } from "@ente/shared/storage/localStorage/helpers";
|
||||
import type { KeyAttributes } from "@ente/shared/user/types";
|
||||
import { HttpStatusCode } from "axios";
|
||||
import { TwoFactorType } from "../constants/twofactor";
|
||||
|
||||
const ENDPOINT = getEndpoint();
|
||||
|
||||
@ -73,9 +72,12 @@ export const verifyTwoFactor = async (code: string, sessionID: string) => {
|
||||
return resp.data as UserVerificationResponse;
|
||||
};
|
||||
|
||||
/** The type of the second factor we're trying to act on */
|
||||
export type TwoFactorType = "totp" | "passkey";
|
||||
|
||||
export const recoverTwoFactor = async (
|
||||
sessionID: string,
|
||||
twoFactorType: TwoFactorType = TwoFactorType.TOTP,
|
||||
twoFactorType: TwoFactorType,
|
||||
) => {
|
||||
const resp = await HTTPService.get(`${ENDPOINT}/users/two-factor/recover`, {
|
||||
sessionID,
|
||||
@ -87,7 +89,7 @@ export const recoverTwoFactor = async (
|
||||
export const removeTwoFactor = async (
|
||||
sessionID: string,
|
||||
secret: string,
|
||||
twoFactorType: TwoFactorType = TwoFactorType.TOTP,
|
||||
twoFactorType: TwoFactorType,
|
||||
) => {
|
||||
const resp = await HTTPService.post(`${ENDPOINT}/users/two-factor/remove`, {
|
||||
sessionID,
|
||||
|
@ -1,4 +0,0 @@
|
||||
export enum TwoFactorType {
|
||||
PASSKEY = "passkey",
|
||||
TOTP = "totp",
|
||||
}
|
@ -1,9 +1,12 @@
|
||||
import log from "@/next/log";
|
||||
import type { BaseAppContextT } from "@/next/types/app";
|
||||
import { ensure } from "@/utils/ensure";
|
||||
import { recoverTwoFactor, removeTwoFactor } from "@ente/accounts/api/user";
|
||||
import {
|
||||
recoverTwoFactor,
|
||||
removeTwoFactor,
|
||||
type TwoFactorType,
|
||||
} from "@ente/accounts/api/user";
|
||||
import { PAGES } from "@ente/accounts/constants/pages";
|
||||
import { TwoFactorType } from "@ente/accounts/constants/twofactor";
|
||||
import { VerticallyCentered } from "@ente/shared/components/Container";
|
||||
import type { DialogBoxAttributesV2 } from "@ente/shared/components/DialogBoxV2/types";
|
||||
import FormPaper from "@ente/shared/components/Form/FormPaper";
|
||||
@ -31,13 +34,10 @@ bip39.setDefaultWordlist("english");
|
||||
|
||||
export interface RecoverPageProps {
|
||||
appContext: BaseAppContextT;
|
||||
twoFactorType?: TwoFactorType;
|
||||
twoFactorType: TwoFactorType;
|
||||
}
|
||||
|
||||
const Page: React.FC<RecoverPageProps> = ({
|
||||
appContext,
|
||||
twoFactorType = TwoFactorType.TOTP,
|
||||
}) => {
|
||||
const Page: React.FC<RecoverPageProps> = ({ appContext, twoFactorType }) => {
|
||||
const { logout } = appContext;
|
||||
|
||||
const [encryptedTwoFactorSecret, setEncryptedTwoFactorSecret] =
|
||||
|
Loading…
x
Reference in New Issue
Block a user