From a9445be97b6c9bf868a83d5e2bff4af09d2f0014 Mon Sep 17 00:00:00 2001 From: zhl Date: Wed, 13 Jan 2021 15:47:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=8E=A5=E5=8F=A3=E7=9A=84?= =?UTF-8?q?=E9=AA=8C=E8=AF=81=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/apiauth.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/apiauth.ts b/src/plugins/apiauth.ts index 8c44943..225d414 100644 --- a/src/plugins/apiauth.ts +++ b/src/plugins/apiauth.ts @@ -28,7 +28,7 @@ const apiAuthPlugin: FastifyPluginAsync = async function( fastify.decorate("apiAuth", async function(request: FastifyRequest, reply: FastifyReply) { if (!request.roles || request.roles.indexOf('anon') == -1) { try { - if (request.roles.indexOf('svr') >= 0) { + if (request.roles && request.roles.indexOf('svr') >= 0) { // TODO: check svr } else { // @ts-ignore