feat(auth): add stepped auth and password recovery flows
This commit is contained in:
@@ -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/"));
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user