From 4b5597b3fe6e02f1655e6a731e83bdcdf1017d63 Mon Sep 17 00:00:00 2001 From: ivarlovlie Date: Mon, 14 Nov 2022 13:56:56 +0700 Subject: refactor: Api files always returns Response --- .../app/src/lib/api/password-reset-request/index.ts | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'code/app/src/lib/api/password-reset-request') diff --git a/code/app/src/lib/api/password-reset-request/index.ts b/code/app/src/lib/api/password-reset-request/index.ts index 9d6f0dc..53cb1d2 100644 --- a/code/app/src/lib/api/password-reset-request/index.ts +++ b/code/app/src/lib/api/password-reset-request/index.ts @@ -1,17 +1,14 @@ -import { api_base } from "$lib/configuration"; -import { http_get_async, http_post_async, type InternalFetchResponse } from "../_fetch"; +import {api_base} from "$lib/configuration"; +import {http_get_async, http_post_async} from "../_fetch"; export const http_password_reset_request = { - create_forgot_password_request(username: string): Promise { - if (!username) throw new Error("Username is empty"); - return http_get_async(api_base("_/forgot-password-requests/create?username=" + username)); + create_request_async(username: string): Promise { + return http_get_async(api_base("_/password-reset-request/create?for_user=" + username)); }, - check_forgot_password_request(public_id: string): Promise { - if (!public_id) throw new Error("Id is empty"); - return http_get_async(api_base("_/forgot-password-requests/is-valid?id=" + public_id)); + check_request_async(publicId: string): Promise { + return http_get_async(api_base("_/password-reset-request/is-valid?id=" + publicId)); }, - fulfill_forgot_password_request(public_id: string, newPassword: string): Promise { - if (!public_id) throw new Error("Id is empty"); - return http_post_async(api_base("_/forgot-password-requests/fulfill"), { id: public_id, newPassword }); + fulfill_request_async(publicId: string, newPassword: string): Promise { + return http_post_async(api_base("_/password-reset-request/fulfill"), {id: publicId, newPassword}); }, -} \ No newline at end of file +}; \ No newline at end of file -- cgit v1.3