use redirect func
This commit is contained in:
parent
1363e9796c
commit
1f984b8006
|
@ -1,19 +1,14 @@
|
||||||
import { getUser } from "@/auth";
|
import { getUser } from "@/auth";
|
||||||
import { getUserInfo } from "@/ldap";
|
import { getUserInfo } from "@/ldap";
|
||||||
import AboutMe from "./AboutMe";
|
import AboutMe from "./AboutMe";
|
||||||
|
import { redirect } from "next/navigation";
|
||||||
|
|
||||||
export default async function Page() {
|
export default async function Page() {
|
||||||
const user = await getUser();
|
const user = await getUser();
|
||||||
if (!user) {
|
if (!user) redirect("/login");
|
||||||
window.location.href = "/login";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const info = await getUserInfo(user);
|
const info = await getUserInfo(user);
|
||||||
if (info === null) {
|
if (info === null) redirect("/login");
|
||||||
window.location.href = "/login";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
return <AboutMe info={info} />;
|
return <AboutMe info={info} />;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,12 @@
|
||||||
import { cookies } from "next/dist/client/components/headers";
|
import { cookies } from "next/dist/client/components/headers";
|
||||||
import styles from "@/app/page.module.css";
|
import styles from "@/app/page.module.css";
|
||||||
import RegisterForm from "./RegisterForm";
|
import RegisterForm from "./RegisterForm";
|
||||||
|
import { redirect } from "next/navigation";
|
||||||
|
|
||||||
export default function Page() {
|
export default function Page() {
|
||||||
const cookieStore = cookies();
|
const cookieStore = cookies();
|
||||||
const ticket = cookieStore.get("ticket");
|
const ticket = cookieStore.get("ticket");
|
||||||
if (ticket === null) {
|
if (ticket === null) redirect("/");
|
||||||
window.location.href = "/";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<main className={styles.main}>
|
<main className={styles.main}>
|
||||||
|
|
Loading…
Reference in New Issue