reduce auth
This commit is contained in:
parent
71a8049a35
commit
b28f6c3d8c
12 changed files with 27 additions and 45 deletions
|
@ -5,6 +5,7 @@ import {
|
|||
logUnhandledErrorsAndRejections,
|
||||
} from "@/next/log-web";
|
||||
import type { AppName, BaseAppContextT } from "@/next/types/app";
|
||||
import { ensure } from "@/utils/ensure";
|
||||
import { accountLogout } from "@ente/accounts/services/logout";
|
||||
import {
|
||||
APPS,
|
||||
|
@ -29,7 +30,7 @@ import { ThemeProvider } from "@mui/material/styles";
|
|||
import { t } from "i18next";
|
||||
import type { AppProps } from "next/app";
|
||||
import { useRouter } from "next/router";
|
||||
import { createContext, useEffect, useRef, useState } from "react";
|
||||
import { createContext, useContext, useEffect, useRef, useState } from "react";
|
||||
import LoadingBar, { type LoadingBarRef } from "react-top-loading-bar";
|
||||
import "../../public/css/global.css";
|
||||
|
||||
|
@ -47,6 +48,9 @@ type AppContextT = BaseAppContextT & {
|
|||
/** The React {@link Context} available to all pages. */
|
||||
export const AppContext = createContext<AppContextT | undefined>(undefined);
|
||||
|
||||
/** Utility hook to reduce amount of boilerplate in account related pages. */
|
||||
export const useAppContext = () => ensure(useContext(AppContext));
|
||||
|
||||
export default function App({ Component, pageProps }: AppProps) {
|
||||
const appName: AppName = "auth";
|
||||
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
import { ensure } from "@/utils/ensure";
|
||||
import Page_ from "@ente/accounts/pages/change-email";
|
||||
import { useContext } from "react";
|
||||
import { AppContext } from "./_app";
|
||||
import { useAppContext } from "./_app";
|
||||
|
||||
const Page = () => <Page_ appContext={ensure(useContext(AppContext))} />;
|
||||
const Page = () => <Page_ appContext={useAppContext()} />;
|
||||
|
||||
export default Page;
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
import { ensure } from "@/utils/ensure";
|
||||
import Page_ from "@ente/accounts/pages/change-password";
|
||||
import { useContext } from "react";
|
||||
import { AppContext } from "./_app";
|
||||
import { useAppContext } from "./_app";
|
||||
|
||||
const Page = () => <Page_ appContext={ensure(useContext(AppContext))} />;
|
||||
const Page = () => <Page_ appContext={useAppContext()} />;
|
||||
|
||||
export default Page;
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
import { ensure } from "@/utils/ensure";
|
||||
import Page_ from "@ente/accounts/pages/credentials";
|
||||
import { useContext } from "react";
|
||||
import { AppContext } from "./_app";
|
||||
import { useAppContext } from "./_app";
|
||||
|
||||
const Page = () => <Page_ appContext={ensure(useContext(AppContext))} />;
|
||||
const Page = () => <Page_ appContext={useAppContext()} />;
|
||||
|
||||
export default Page;
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
import { ensure } from "@/utils/ensure";
|
||||
import Page_ from "@ente/accounts/pages/generate";
|
||||
import { useContext } from "react";
|
||||
import { AppContext } from "./_app";
|
||||
import { useAppContext } from "./_app";
|
||||
|
||||
const Page = () => <Page_ appContext={ensure(useContext(AppContext))} />;
|
||||
const Page = () => <Page_ appContext={useAppContext()} />;
|
||||
|
||||
export default Page;
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
import { ensure } from "@/utils/ensure";
|
||||
import Page_ from "@ente/accounts/pages/login";
|
||||
import { useContext } from "react";
|
||||
import { AppContext } from "./_app";
|
||||
import { useAppContext } from "./_app";
|
||||
|
||||
const Page = () => <Page_ appContext={ensure(useContext(AppContext))} />;
|
||||
const Page = () => <Page_ appContext={useAppContext()} />;
|
||||
|
||||
export default Page;
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
import { ensure } from "@/utils/ensure";
|
||||
import Page_ from "@ente/accounts/pages/recover";
|
||||
import { useContext } from "react";
|
||||
import { AppContext } from "./_app";
|
||||
import { useAppContext } from "./_app";
|
||||
|
||||
const Page = () => <Page_ appContext={ensure(useContext(AppContext))} />;
|
||||
const Page = () => <Page_ appContext={useAppContext()} />;
|
||||
|
||||
export default Page;
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
import { ensure } from "@/utils/ensure";
|
||||
import Page_ from "@ente/accounts/pages/signup";
|
||||
import { useContext } from "react";
|
||||
import { AppContext } from "./_app";
|
||||
import { useAppContext } from "./_app";
|
||||
|
||||
const Page = () => <Page_ appContext={ensure(useContext(AppContext))} />;
|
||||
const Page = () => <Page_ appContext={useAppContext()} />;
|
||||
|
||||
export default Page;
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
import { ensure } from "@/utils/ensure";
|
||||
import Page_ from "@ente/accounts/pages/two-factor/recover";
|
||||
import { useContext } from "react";
|
||||
import { AppContext } from "../_app";
|
||||
import { useAppContext } from "../_app";
|
||||
|
||||
const Page = () => <Page_ appContext={ensure(useContext(AppContext))} />;
|
||||
const Page = () => <Page_ appContext={useAppContext()} />;
|
||||
|
||||
export default Page;
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
import { ensure } from "@/utils/ensure";
|
||||
import Page_ from "@ente/accounts/pages/two-factor/setup";
|
||||
import { useContext } from "react";
|
||||
import { AppContext } from "../_app";
|
||||
import { useAppContext } from "../_app";
|
||||
|
||||
const Page = () => <Page_ appContext={ensure(useContext(AppContext))} />;
|
||||
const Page = () => <Page_ appContext={useAppContext()} />;
|
||||
|
||||
export default Page;
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
import { ensure } from "@/utils/ensure";
|
||||
import Page_ from "@ente/accounts/pages/two-factor/verify";
|
||||
import { useContext } from "react";
|
||||
import { AppContext } from "../_app";
|
||||
import { useAppContext } from "../_app";
|
||||
|
||||
const Page = () => <Page_ appContext={ensure(useContext(AppContext))} />;
|
||||
const Page = () => <Page_ appContext={useAppContext()} />;
|
||||
|
||||
export default Page;
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
import { ensure } from "@/utils/ensure";
|
||||
import Page_ from "@ente/accounts/pages/verify";
|
||||
import { useContext } from "react";
|
||||
import { AppContext } from "./_app";
|
||||
import { useAppContext } from "./_app";
|
||||
|
||||
const Page = () => <Page_ appContext={ensure(useContext(AppContext))} />;
|
||||
const Page = () => <Page_ appContext={useAppContext()} />;
|
||||
|
||||
export default Page;
|
||||
|
|
Loading…
Reference in a new issue