refactor: remove login/auth for public dashboard
Deploy to VPS / deploy (push) Failing after 34s
Deploy to VPS / deploy (push) Failing after 34s
- Remove login page, redirect / to /dashboard directly - Remove AuthProvider, DashboardGuard from dashboard layout - Remove use-auth hook and auth API module - Remove X-Admin-Password header from API client - Remove logout button from sidebar
This commit is contained in:
@@ -1,13 +0,0 @@
|
||||
import { ApiError, api } from "./client";
|
||||
|
||||
export async function login(password: string): Promise<boolean> {
|
||||
try {
|
||||
const resp = await api.post<{ ok: boolean }>("/api/auth/login", {
|
||||
password,
|
||||
});
|
||||
return resp.ok;
|
||||
} catch (err) {
|
||||
if (err instanceof ApiError) return false;
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
@@ -12,27 +12,17 @@ function getBaseUrl(): string {
|
||||
if (typeof window === "undefined") return "";
|
||||
const protocol = window.location.protocol.replace(":", "");
|
||||
const host = window.location.host;
|
||||
// In dev, Next.js proxy can be configured, but default to same-host assumption
|
||||
return `${protocol}://${host}`;
|
||||
}
|
||||
|
||||
function getAuthHeader(): string | null {
|
||||
if (typeof window === "undefined") return null;
|
||||
return localStorage.getItem("admin-password");
|
||||
}
|
||||
|
||||
export async function apiRequest<T>(
|
||||
method: string,
|
||||
path: string,
|
||||
body?: unknown,
|
||||
): Promise<T> {
|
||||
const url = `${getBaseUrl()}${path}`;
|
||||
const password = getAuthHeader();
|
||||
|
||||
const headers: Record<string, string> = {};
|
||||
if (password) {
|
||||
headers["X-Admin-Password"] = password;
|
||||
}
|
||||
if (body !== undefined) {
|
||||
headers["Content-Type"] = "application/json";
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
export { login } from "./auth";
|
||||
export { ApiError, api, apiRequest } from "./client";
|
||||
export { configApi } from "./config";
|
||||
export { dashboardApi } from "./dashboard";
|
||||
|
||||
Reference in New Issue
Block a user