feat: implement admin authentication overlay and API integration for secure access to voice and media controls

This commit is contained in:
MythEclipse
2026-05-17 00:20:29 +07:00
parent a5b5ccf5b0
commit 05feb697f0
6 changed files with 134 additions and 28 deletions
+8
View File
@@ -0,0 +1,8 @@
import { request } from "./client";
export async function login(password: string): Promise<{ ok: boolean }> {
return request<{ ok: boolean }>('/api/auth/login', {
method: 'POST',
body: JSON.stringify({ password }),
});
}
+5 -1
View File
@@ -50,8 +50,12 @@ class ApiError extends Error {
}
export async function request<T>(path: string, init?: RequestInit): Promise<T> {
const password = localStorage.getItem("admin-password");
const res = await fetch(path, {
headers: { "Content-Type": "application/json" },
headers: {
"Content-Type": "application/json",
...(password ? { "X-Admin-Password": password } : {}),
},
...init,
});