This commit is contained in:
2026-05-19 15:10:42 +03:00
parent 22ceb8e2b4
commit 36196a882f
10 changed files with 234 additions and 1 deletions

View File

@@ -68,3 +68,41 @@ export async function uploadAvatar(payload: UploadAvatarPayload): Promise<MeResp
if (!res.ok) throw data
return data
}
export async function passwordResetStart(): Promise<void> {
const csrf = await getCsrfToken()
const res = await fetch(`${USERS_API_URL}/me/settings/password/start`, {
method: 'POST',
credentials: 'include',
headers: {
'X-CSRF-Token': csrf,
},
})
if (!res.ok) {
const data = await res.json().catch(() => ({}))
throw data
}
}
export interface PasswordResetCompletePayload {
code: string
new_password: string
confirm_password: string
}
export async function passwordResetComplete(payload: PasswordResetCompletePayload): Promise<void> {
const csrf = await getCsrfToken()
const res = await fetch(`${USERS_API_URL}/me/settings/password/complete`, {
method: 'POST',
credentials: 'include',
headers: {
'Content-Type': 'application/json',
'X-CSRF-Token': csrf,
},
body: JSON.stringify(payload),
})
if (!res.ok) {
const data = await res.json().catch(() => ({}))
throw data
}
}