/** * Password reset / initial set-password flows (legacy CI `user/*` auth views). * Backend expected under `/api/v1/auth/...`. */ import { apiFetch } from './http' export async function requestForgotPassword(email: string): Promise<{ ok?: boolean; message?: string }> { return apiFetch('/api/v1/auth/forgot-password', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ email: email.trim() }), }) } export async function submitPasswordReset(payload: { token: string password: string pass_confirm: string }): Promise<{ ok?: boolean; message?: string }> { return apiFetch('/api/v1/auth/reset-password', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(payload), }) } export async function submitSetPassword(payload: { user_id: number | string token: string password: string password_confirm: string }): Promise<{ ok?: boolean; message?: string }> { return apiFetch('/api/v1/auth/set-password', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(payload), }) } export async function submitAuthorizedUserPassword( userId: number | string, payload: { token: string; password: string; password_confirm: string }, ): Promise<{ ok?: boolean; message?: string }> { return apiFetch(`/api/v1/auth/set-authorized-user-password/${encodeURIComponent(String(userId))}`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(payload), }) }