feat: use session cookie auth for public dashboard password flow

handlePasswordSubmit now calls POST /public/sites/:id/auth which
sets an HttpOnly cookie. All subsequent API calls authenticate via
cookie automatically — no password in URLs, no captcha state needed
for data fetching. Simplifies share page state management.
This commit is contained in:
Usman Baig
2026-03-22 14:45:25 +01:00
parent 82a201a043
commit 430e6f5d48
2 changed files with 48 additions and 64 deletions

View File

@@ -117,6 +117,21 @@ export interface FrustrationByPage {
unique_elements: number
}
// ─── Public Auth ─────────────────────────────────────────────────────
export function authenticatePublicDashboard(siteId: string, password: string, captchaToken?: string, captchaId?: string, captchaSolution?: string): Promise<{ status: string }> {
return apiRequest<{ status: string }>(`/public/sites/${siteId}/auth`, {
method: 'POST',
body: JSON.stringify({
password,
captcha_token: captchaToken || '',
captcha_id: captchaId || '',
captcha_solution: captchaSolution || '',
}),
credentials: 'include',
})
}
// ─── Helpers ────────────────────────────────────────────────────────
function appendAuthParams(params: URLSearchParams, auth?: AuthParams) {