feat(auth): add stepped auth and password recovery flows

This commit is contained in:
2026-05-03 17:10:02 +03:30
parent 9b1cd772fb
commit 380b794ab1
19 changed files with 1857 additions and 687 deletions

View File

@@ -29,6 +29,49 @@ export const loginWithOtp = async (mobile: string, otp: string) => {
return response.json();
};
export const registerWithOtp = async (
mobile: string,
code: string,
password: string,
re_password: string,
first_name = "",
last_name = "",
) => {
const response = await authFetch("/api/users/register/", {
method: "POST",
body: JSON.stringify({ mobile, code, password, re_password, first_name, last_name }),
})
if (!response.ok) throw await buildApiError(response)
return response.json()
}
export const resetPasswordWithOtp = async (
mobile: string,
code: string,
password: string,
re_password: string,
) => {
const response = await authFetch("/api/users/password/reset/", {
method: "POST",
body: JSON.stringify({ mobile, code, password, re_password }),
})
if (!response.ok) throw await buildApiError(response)
return response.json()
}
export const changePassword = async (
old_password: string,
new_password: string,
re_password: string,
) => {
const response = await authFetch("/api/users/password/change/", {
method: "PATCH",
body: JSON.stringify({ old_password, new_password, re_password }),
})
if (!response.ok) throw await buildApiError(response)
return response.json()
}
export const startGoogleLogin = () => {
window.location.assign(buildApiUrl("/api/users/oauth/google/start/"));
};