From 25f2bd2ae4112224596290e620cde0b0161dbd06 Mon Sep 17 00:00:00 2001 From: Fabian Stamm Date: Wed, 28 Oct 2020 06:06:17 +0100 Subject: [PATCH] Making uid more compatible --- src/web/v1/index.ts | 1 + src/websocket.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/src/web/v1/index.ts b/src/web/v1/index.ts index 1c44d4a..33bf6de 100644 --- a/src/web/v1/index.ts +++ b/src/web/v1/index.ts @@ -38,6 +38,7 @@ V1.post("/db/:database/query", async (ctx) => { if (authkey && db.publickey) { let res = await verifyJWT(authkey, db.publickey); + if (res && !res.uid && res.user) res.uid = res.user; if (!res || !res.uid) { throw new BadRequestError("Invalid JWT"); } else { diff --git a/src/websocket.ts b/src/websocket.ts index 4293ad1..4ed7419 100644 --- a/src/websocket.ts +++ b/src/websocket.ts @@ -55,6 +55,7 @@ export class WebsocketConnectionManager { const authkey = query.get("authkey"); if (authkey && db.publickey) { let res = await verifyJWT(authkey, db.publickey); + if (res && !res.uid && res.user) res.uid = res.user; if (!res || !res.uid) { sendError("Invalid JWT"); socket.close();