From 365b0cf259e9a49b0e7680f865bb9fba61838056 Mon Sep 17 00:00:00 2001 From: GUL Date: Thu, 9 Nov 2023 12:53:00 +0100 Subject: [PATCH] fix: fix reading auth credentials (@HEYGUL) * fix: fix reading auth credentials --- src/plugin.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/plugin.ts b/src/plugin.ts index 3c3239b..b4c7244 100644 --- a/src/plugin.ts +++ b/src/plugin.ts @@ -150,7 +150,9 @@ const register = async (server: Hapi.Server, options: ExtendedAdminJSOptions) => options: opts, handler: async (request, h) => { try { - const loggedInUser = request.auth?.credentials?.[0]; + const loggedInUser = Array.isArray(request.auth?.credentials) + ? request.auth?.credentials?.[0] + : request.auth?.credentials; const controller = new route.Controller({ admin }, loggedInUser); const ret = await controller[route.action](request, h); const response = h.response(ret);