feat: email resetting frontend code

This commit is contained in:
swve 2024-03-19 21:51:26 +01:00
parent 15677a6946
commit 1987e56b9a
9 changed files with 451 additions and 5 deletions

View file

@ -1,4 +1,5 @@
import { getAPIUrl } from '@services/config/config'
import { RequestBody, getResponseMetadata } from '@services/utils/ts/requests'
interface LoginAndGetTokenResponse {
access_token: 'string'
@ -36,6 +37,29 @@ export async function loginAndGetToken(
return response
}
export async function sendResetLink(email: string, org_id: number) {
const result = await fetch(
`${getAPIUrl()}users/reset_password/send_reset_code/${email}?org_id=${org_id}`,
RequestBody('POST', null, null)
)
const res = await getResponseMetadata(result)
return res
}
export async function resetPassword(
email: string,
new_password: string,
org_id: number,
reset_code: string
) {
const result = await fetch(
`${getAPIUrl()}users/reset_password/change_password/${email}?reset_code=${reset_code}&new_password=${new_password}&org_id=${org_id}`,
RequestBody('POST', null, null)
)
const res = await getResponseMetadata(result)
return res
}
export async function logout(): Promise<any> {
// Request Config