protected
This commit is contained in:
@@ -1,6 +1,18 @@
|
|||||||
import { createSignal, For, Show } from "solid-js";
|
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";
|
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 = {
|
type EndpointTest = {
|
||||||
name: string;
|
name: string;
|
||||||
router: string;
|
router: string;
|
||||||
@@ -846,6 +858,8 @@ const routerSections: RouterSection[] = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
export default function TestPage() {
|
export default function TestPage() {
|
||||||
|
const authState = createAsync(() => getAuthState());
|
||||||
|
|
||||||
const [expandedSections, setExpandedSections] = createSignal<Set<string>>(
|
const [expandedSections, setExpandedSections] = createSignal<Set<string>>(
|
||||||
new Set()
|
new Set()
|
||||||
);
|
);
|
||||||
@@ -919,6 +933,17 @@ export default function TestPage() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
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">
|
<main class="min-h-screen p-8">
|
||||||
<div class="mx-auto max-w-6xl">
|
<div class="mx-auto max-w-6xl">
|
||||||
<div class="bg-surface0 mb-6 rounded-lg p-6 shadow-lg">
|
<div class="bg-surface0 mb-6 rounded-lg p-6 shadow-lg">
|
||||||
@@ -951,7 +976,9 @@ export default function TestPage() {
|
|||||||
>
|
>
|
||||||
<div class="text-left">
|
<div class="text-left">
|
||||||
<h2 class="text-xl font-bold">{section.name}</h2>
|
<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">
|
<p class="text-subtext1 mt-1 text-xs">
|
||||||
{section.endpoints.length} endpoint
|
{section.endpoints.length} endpoint
|
||||||
{section.endpoints.length !== 1 ? "s" : ""}
|
{section.endpoints.length !== 1 ? "s" : ""}
|
||||||
@@ -1110,7 +1137,8 @@ export default function TestPage() {
|
|||||||
utilities
|
utilities
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<strong>Lineage Misc</strong> - Offline Secret, Get Opponents
|
<strong>Lineage Misc</strong> - Offline Secret, Get
|
||||||
|
Opponents
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<strong>Lineage PvP</strong> - Get Opponents
|
<strong>Lineage PvP</strong> - Get Opponents
|
||||||
@@ -1128,15 +1156,15 @@ export default function TestPage() {
|
|||||||
<strong>Example Router</strong> - Get Profile
|
<strong>Example Router</strong> - Get Profile
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<strong>User Router</strong> - All endpoints (profile updates,
|
<strong>User Router</strong> - All endpoints (profile
|
||||||
password, account deletion)
|
updates, password, account deletion)
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<strong>Lineage Auth</strong> - Email Login, Refresh Token
|
<strong>Lineage Auth</strong> - Email Login, Refresh Token
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<strong>Lineage Database</strong> - Get Credentials, Deletion
|
<strong>Lineage Database</strong> - Get Credentials,
|
||||||
endpoints
|
Deletion endpoints
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
@@ -1178,8 +1206,8 @@ export default function TestPage() {
|
|||||||
comments/likes → upload images via S3
|
comments/likes → upload images via S3
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<strong>Lineage game data:</strong> Fetch JSON data → register
|
<strong>Lineage game data:</strong> Fetch JSON data →
|
||||||
character → find PvP opponents
|
register character → find PvP opponents
|
||||||
</li>
|
</li>
|
||||||
</ol>
|
</ol>
|
||||||
</div>
|
</div>
|
||||||
@@ -1196,5 +1224,6 @@ export default function TestPage() {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
|
</Show>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user