protected
This commit is contained in:
@@ -1,6 +1,18 @@
|
||||
import { createSignal, For, Show } from "solid-js";
|
||||
import { query, createAsync } from "@solidjs/router";
|
||||
import { getRequestEvent } from "solid-js/web";
|
||||
import { getPrivilegeLevel } from "~/server/utils";
|
||||
import { api } from "~/lib/api";
|
||||
|
||||
const getAuthState = query(async () => {
|
||||
"use server";
|
||||
|
||||
const event = getRequestEvent()!;
|
||||
const privilegeLevel = await getPrivilegeLevel(event.nativeEvent);
|
||||
|
||||
return { privilegeLevel };
|
||||
}, "test-auth-state");
|
||||
|
||||
type EndpointTest = {
|
||||
name: string;
|
||||
router: string;
|
||||
@@ -846,6 +858,8 @@ const routerSections: RouterSection[] = [
|
||||
];
|
||||
|
||||
export default function TestPage() {
|
||||
const authState = createAsync(() => getAuthState());
|
||||
|
||||
const [expandedSections, setExpandedSections] = createSignal<Set<string>>(
|
||||
new Set()
|
||||
);
|
||||
@@ -919,6 +933,17 @@ export default function TestPage() {
|
||||
};
|
||||
|
||||
return (
|
||||
<Show
|
||||
when={authState()?.privilegeLevel === "admin"}
|
||||
fallback={
|
||||
<div class="w-full pt-[30vh] text-center">
|
||||
<div class="text-text text-2xl">Unauthorized</div>
|
||||
<div class="text-subtext0 mt-4">
|
||||
You must be an admin to access this page.
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
>
|
||||
<main class="min-h-screen p-8">
|
||||
<div class="mx-auto max-w-6xl">
|
||||
<div class="bg-surface0 mb-6 rounded-lg p-6 shadow-lg">
|
||||
@@ -951,7 +976,9 @@ export default function TestPage() {
|
||||
>
|
||||
<div class="text-left">
|
||||
<h2 class="text-xl font-bold">{section.name}</h2>
|
||||
<p class="text-subtext0 text-sm">{section.description}</p>
|
||||
<p class="text-subtext0 text-sm">
|
||||
{section.description}
|
||||
</p>
|
||||
<p class="text-subtext1 mt-1 text-xs">
|
||||
{section.endpoints.length} endpoint
|
||||
{section.endpoints.length !== 1 ? "s" : ""}
|
||||
@@ -1110,7 +1137,8 @@ export default function TestPage() {
|
||||
utilities
|
||||
</li>
|
||||
<li>
|
||||
<strong>Lineage Misc</strong> - Offline Secret, Get Opponents
|
||||
<strong>Lineage Misc</strong> - Offline Secret, Get
|
||||
Opponents
|
||||
</li>
|
||||
<li>
|
||||
<strong>Lineage PvP</strong> - Get Opponents
|
||||
@@ -1128,15 +1156,15 @@ export default function TestPage() {
|
||||
<strong>Example Router</strong> - Get Profile
|
||||
</li>
|
||||
<li>
|
||||
<strong>User Router</strong> - All endpoints (profile updates,
|
||||
password, account deletion)
|
||||
<strong>User Router</strong> - All endpoints (profile
|
||||
updates, password, account deletion)
|
||||
</li>
|
||||
<li>
|
||||
<strong>Lineage Auth</strong> - Email Login, Refresh Token
|
||||
</li>
|
||||
<li>
|
||||
<strong>Lineage Database</strong> - Get Credentials, Deletion
|
||||
endpoints
|
||||
<strong>Lineage Database</strong> - Get Credentials,
|
||||
Deletion endpoints
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
@@ -1178,8 +1206,8 @@ export default function TestPage() {
|
||||
comments/likes → upload images via S3
|
||||
</li>
|
||||
<li>
|
||||
<strong>Lineage game data:</strong> Fetch JSON data → register
|
||||
character → find PvP opponents
|
||||
<strong>Lineage game data:</strong> Fetch JSON data →
|
||||
register character → find PvP opponents
|
||||
</li>
|
||||
</ol>
|
||||
</div>
|
||||
@@ -1196,5 +1224,6 @@ export default function TestPage() {
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
</Show>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user