From 60e574d2b1369f31a85d0975fad6e7c818b5c709 Mon Sep 17 00:00:00 2001 From: EETagent Date: Sun, 4 Dec 2022 14:44:31 +0100 Subject: [PATCH] feat: admin ssr logout --- frontend/src/lib/@api/admin.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/frontend/src/lib/@api/admin.ts b/frontend/src/lib/@api/admin.ts index dd54940..e98595f 100644 --- a/frontend/src/lib/@api/admin.ts +++ b/frontend/src/lib/@api/admin.ts @@ -38,6 +38,24 @@ export const resetCandidatePassword = async (id: number): Promise { + try { + if (fetchSsr) { + const res = await fetchSsr(API_URL + '/admin/logout', { + method: 'POST', + credentials: 'include' + }); + return await res.text(); + } + const res = await axios.post(API_URL + '/admin/logout', { withCredentials: true }); + return res.data; + } catch (e: any) { + throw errorHandler(e, 'Logout failed'); + } +}; + // SSR compatible // List all candidates /admin/list/candidates export const apiListCandidates = async (fetchSsr?: Fetch): Promise<[CandidatePreview]> => {