feat: add authenticated admin shell
Quality / test (push) Canceled after 0s

This commit is contained in:
2026-09-08 22:25:29 -04:00
parent a21d1ae854
commit 86c60f9381
10 changed files with 182 additions and 1 deletions
+24
View File
@@ -0,0 +1,24 @@
const apiBaseUrl = import.meta.env?.VITE_API_BASE_URL ?? '/api/v1';
async function request(path, options = {}) {
const response = await fetch(`${apiBaseUrl}${path}`, {
credentials: 'include',
...options,
headers: { 'content-type': 'application/json', ...options.headers },
});
const payload = await response.json().catch(() => null);
if (!response.ok) throw new Error(payload?.error?.message ?? 'Authentication request failed.');
return payload?.data;
}
export function login(email, password) {
return request('/auth/login', { method: 'POST', body: JSON.stringify({ email, password }) });
}
export function getCurrentPrincipal() {
return request('/auth/me');
}
export function logout(csrfToken) {
return request('/auth/logout', { method: 'POST', headers: { 'x-csrf-token': csrfToken } });
}