🐛 Fix styles issue
This commit is contained in:
parent
3264c85b39
commit
c3636c23ff
@ -12,22 +12,26 @@ export default function RootLayout(props: any) {
|
|||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const userinfo = useUserinfo();
|
const userinfo = useUserinfo();
|
||||||
|
|
||||||
const location = useLocation();
|
|
||||||
const [searchParams] = useSearchParams();
|
const [searchParams] = useSearchParams();
|
||||||
|
const location = useLocation();
|
||||||
|
|
||||||
createEffect(() => {
|
createEffect(() => {
|
||||||
if (ready()) {
|
if (ready()) {
|
||||||
keepGate(location.pathname + location.search);
|
keepGate(location.pathname + location.search, searchParams["embedded"] != null);
|
||||||
}
|
}
|
||||||
}, [ready, userinfo, location]);
|
}, [ready, userinfo, location]);
|
||||||
|
|
||||||
function keepGate(path: string, e?: BeforeLeaveEventArgs) {
|
function keepGate(path: string, embedded: boolean, e?: BeforeLeaveEventArgs) {
|
||||||
const pathname = path.split("?")[0];
|
const pathname = path.split("?")[0];
|
||||||
const whitelist = ["/auth/login", "/auth/register", "/users/me/confirm"];
|
const whitelist = ["/auth/login", "/auth/register", "/users/me/confirm"];
|
||||||
|
|
||||||
if (!userinfo?.isLoggedIn && !whitelist.includes(pathname)) {
|
if (!userinfo?.isLoggedIn && !whitelist.includes(pathname)) {
|
||||||
if (!e?.defaultPrevented) e?.preventDefault();
|
if (!e?.defaultPrevented) e?.preventDefault();
|
||||||
navigate(`/auth/login?redirect_uri=${encodeURIComponent(path)}`);
|
if (embedded) {
|
||||||
|
navigate(`/auth/login?redirect_uri=${encodeURIComponent(path)}&embedded=yes`);
|
||||||
|
} else {
|
||||||
|
navigate(`/auth/login?redirect_uri=${encodeURIComponent(path)}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user