@samitouri / QOSami-HFS / commits / fea544b8

better api

Massimo Melina committed Aug 9, 2023 at 18:37 UTC fea544b80b3854d8647ca4ee0cb4de29033e23ba
2 files changed +3 -3
admin/src/api.ts
+2 -2
@@ -13,7 +13,7 @@ export * from '@hfs/shared/api'
13 setDefaultApiCallOptions({
14 async onResponse(res: Response, body: any) {
15 if (res.status === 401) {
16 - state.loginRequired = body?.any !== false || 403
16 + state.loginRequired = body?.possible !== false || 403
17 throw new ApiError(res.status, "Unauthorized")
18 }
19 }
@@ -79,7 +79,7 @@ export function useApiList<T=any>(cmd:string|Falsy, params: Dict={}, { map=((x:a
79 }
80 if (op === 'error') {
81 if (par === 401)
82 - state.loginRequired = msg[2].any !== false || 403
82 + state.loginRequired = msg[2].possible !== false || 403
83 else
84 setError(err2msg(par))
85 return
src/adminApis.ts
+1 -1
@@ -178,7 +178,7 @@ for (const [k, was] of Object.entries(adminApis))
178 return new ApiError(HTTP_FORBIDDEN)
179 if (ctxAdminAccess(ctx))
180 return was(params, ctx)
181 - const props = { any: anyAccountCanLoginAdmin() }
181 + const props = { possible: anyAccountCanLoginAdmin() }
182 return ctx.headers.accept === 'text/event-stream'
183 ? new SendListReadable({ doAtStart: x => x.error(HTTP_UNAUTHORIZED, true, props) })
184 : new ApiError(HTTP_UNAUTHORIZED, props)