reverted to logout api
Massimo Melina committed
Jun 17, 2024 at 12:31 UTC
9fc018e6e037c5b4beb77bc042157f203f650e7b
2 files changed
+6
-4
frontend/src/login.ts
+5
-4
@@ -32,14 +32,15 @@ const sessionRefresher = makeSessionRefresher(state)
32
sessionRefresher(getHFS().session)
33
34
export function logout() {
35
- // browsers (chrome125) memorize basic-auth credentials based on the path. Returning 401 on /~/api won't be effective on other paths, so we make a call "here" (as doing the same on / wasn't effective).
36
- return fetch('?get=logout', { credentials: 'include' }).then(res => { // had to add 'credentials' for ff52: no cookie = no reset-cookie
37
- if (res.status !== HTTP_UNAUTHORIZED) // we expect this error code
35
+ return apiCall('logout', {}, { modal: working }).catch(res => {
36
+ if (res.code !== HTTP_UNAUTHORIZED) // we expect this error code
37
throw res
38
state.username = ''
39
+ if (fallbackToBasicAuth())
40
+ return location.reload() // reloading avoids nasty warnings with ff52
41
reloadList()
42
toast(t`Logged out`, 'success')
42
- }).finally(working())
43
+ })
44
}
45
46
export let closeLoginDialog: undefined | (() => void)
src/api.auth.ts
+1
@@ -67,6 +67,7 @@ export const loginSrp2: ApiHandler = async ({ pubKey, proof }, ctx) => {
67
}
68
}
69
70
+// this api is here for consistency, but frontend is actually using
71
export const logout: ApiHandler = async ({}, ctx) => {
72
if (!ctx.session)
73
return new ApiError(HTTP_SERVER_ERROR)