refactor: remove login/auth for public dashboard
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:
asepharyana
2026-07-26 11:30:27 +07:00
parent 5e01ec0806
commit f9f1313ccd
7 changed files with 17 additions and 258 deletions
@@ -1,78 +0,0 @@
"use client";
import {
createContext,
type ReactNode,
useCallback,
useContext,
useEffect,
useState,
} from "react";
import { login } from "@/lib/api";
interface AuthContextValue {
authenticated: boolean;
loading: boolean;
login: (password: string) => Promise<boolean>;
logout: () => void;
}
const AuthContext = createContext<AuthContextValue | null>(null);
export function AuthProvider({ children }: { children: ReactNode }) {
const [authenticated, setAuthenticated] = useState(false);
const [loading, setLoading] = useState(true);
useEffect(() => {
const password = localStorage.getItem("admin-password");
if (password) {
// Verify stored password still works
login(password)
.then((ok) => {
setAuthenticated(ok);
setLoading(false);
})
.catch(() => {
localStorage.removeItem("admin-password");
setLoading(false);
});
} else {
setLoading(false);
}
}, []);
const handleLogin = useCallback(async (password: string) => {
const ok = await login(password);
if (ok) {
localStorage.setItem("admin-password", password);
setAuthenticated(true);
}
return ok;
}, []);
const handleLogout = useCallback(() => {
localStorage.removeItem("admin-password");
setAuthenticated(false);
}, []);
return (
<AuthContext.Provider
value={{
authenticated,
loading,
login: handleLogin,
logout: handleLogout,
}}
>
{children}
</AuthContext.Provider>
);
}
export function useAuth(): AuthContextValue {
const ctx = useContext(AuthContext);
if (!ctx) {
throw new Error("useAuth must be used within an AuthProvider");
}
return ctx;
}