completed middleware
This commit is contained in:
+1
-1
@@ -22,7 +22,7 @@ export async function middleware(req) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (authenticationPages.includes(pathname) && !authenticated) {
|
if (authenticationPages.includes(pathname) && !authenticated) {
|
||||||
return NextResponse.redirect(new URL("/auth/", origin));
|
return NextResponse.redirect(new URL("/auth/login", origin));
|
||||||
}
|
}
|
||||||
|
|
||||||
return NextResponse.next();
|
return NextResponse.next();
|
||||||
|
|||||||
@@ -10,12 +10,13 @@ import { useRouter } from "next/router";
|
|||||||
const AuthRoute = ({ children }) => {
|
const AuthRoute = ({ children }) => {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
const isAuthenticated = false; // In a real application, this would be determined based on the user's authentication status.
|
useEffect(() => {
|
||||||
|
const isAuthenticated = false; // In a real application, this would be determined based on the user's authentication status.
|
||||||
|
|
||||||
if (!isAuthenticated) {
|
if (!isAuthenticated) {
|
||||||
router.push("/");
|
router.push("/");
|
||||||
return null;
|
}
|
||||||
}
|
}, []);
|
||||||
|
|
||||||
return <>{children}</>;
|
return <>{children}</>;
|
||||||
};
|
};
|
||||||
|
|||||||
+2
-2
@@ -23,11 +23,11 @@ function MyApp({ Component, pageProps }) {
|
|||||||
<>
|
<>
|
||||||
<ThemeProvider theme={theme}>
|
<ThemeProvider theme={theme}>
|
||||||
<CssBaseline />
|
<CssBaseline />
|
||||||
<AuthRoute>
|
{/* <AuthRoute> */}
|
||||||
<Layout>
|
<Layout>
|
||||||
<Component {...pageProps} />
|
<Component {...pageProps} />
|
||||||
</Layout>
|
</Layout>
|
||||||
</AuthRoute>
|
{/* </AuthRoute> */}
|
||||||
</ThemeProvider>
|
</ThemeProvider>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user