fix: 401 on loginSrp1 was triggering "no admin" message

Massimo Melina committed Feb 3, 2023 at 20:01 UTC 6ef2396cd35285fe7c265e31922d5a175d69841f
1 file changed +2 -2
admin/src/api.ts
+2 -2
@@ -49,7 +49,7 @@ export function apiCall(cmd: string, params?: Dict, { timeout=undefined }={}) :
49 const msg = await res.text() || 'Failed API ' + cmd
50 console.warn(msg + (params ? ' ' + JSON.stringify(params) : ''))
51 if (res.status === 401)
52 - state.loginRequired = Boolean(try_(() => JSON.parse(msg)?.any)) || 403
52 + state.loginRequired = try_(() => JSON.parse(msg)?.any) !== false || 403
53 throw new ApiError(res.status, msg)
54 }, err => {
55 if (err?.message?.includes('fetch'))
@@ -185,7 +185,7 @@ export function useApiList<T=any>(cmd:string|Falsy, params: Dict={}, { addId=fal
185 }
186 if (entry.error) {
187 if (entry.error === 401)
188 - state.loginRequired = entry.any || 403
188 + state.loginRequired = entry.any !== false || 403
189 else
190 setError(err2msg(entry.error))
191 return