auth querying consolidation

This commit is contained in:
2026-01-06 23:26:51 -05:00
parent 08a9ad35af
commit 445ab6d7de
10 changed files with 224 additions and 91 deletions

View File

@@ -1,17 +1,14 @@
import { createSignal, Show, For, createEffect, ErrorBoundary } from "solid-js";
import { PageHead } from "~/components/PageHead";
import { redirect, query, createAsync, useNavigate } from "@solidjs/router";
import { getEvent } from "vinxi/http";
import { api } from "~/lib/api";
const checkAdmin = query(async (): Promise<boolean> => {
"use server";
const { getUserID } = await import("~/server/auth");
const { env } = await import("~/env/server");
const event = getEvent()!;
const userId = await getUserID(event);
const { getUserState } = await import("~/lib/auth-query");
const userState = await getUserState();
if (!userId || userId !== env.ADMIN_ID) {
if (userState.privilegeLevel !== "admin") {
throw redirect("/");
}