mirror of
https://github.com/yashgo0018/maci-wrapper.git
synced 2026-04-12 03:00:25 -04:00
20 lines
455 B
TypeScript
20 lines
455 B
TypeScript
import { useEffect } from "react";
|
|
import { redirect } from "next/navigation";
|
|
import { useAuthContext } from "~~/contexts/AuthContext";
|
|
|
|
export function useAuthUserOnly({ inverted }: { inverted?: boolean }) {
|
|
const { isRegistered } = useAuthContext();
|
|
|
|
useEffect(() => {
|
|
if (inverted && isRegistered) {
|
|
redirect("/polls");
|
|
}
|
|
|
|
if (!inverted && !isRegistered) {
|
|
redirect("/");
|
|
}
|
|
}, [isRegistered, inverted]);
|
|
|
|
return;
|
|
}
|