From 23bc43336852e5864bc5c42aef7325f52713c17e Mon Sep 17 00:00:00 2001 From: zhl Date: Wed, 31 May 2023 15:25:09 +0800 Subject: [PATCH] change response data of unauth --- src/plugins/apiauth.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/plugins/apiauth.ts b/src/plugins/apiauth.ts index 8ff5f03..7f5b0bd 100644 --- a/src/plugins/apiauth.ts +++ b/src/plugins/apiauth.ts @@ -27,12 +27,12 @@ const apiAuthPlugin: FastifyPluginAsync = async function (fastif if (!request.roles || request.roles.indexOf('anon') == -1) { try { if (!request.token) { - return reply.send({ code: 11, msg: 'need login' }) + return reply.send({ errcode: 11, errmsg: 'need login' }) } //@ts-ignore const data = this.jwt.verify(request.token) if (!data || !data.id) { - return reply.send({ code: 10, msg: 'need login' }) + return reply.send({ errcode: 10, errmsg: 'need login' }) } // let account = await Account.findById(data.id) // if (!account) { @@ -40,7 +40,7 @@ const apiAuthPlugin: FastifyPluginAsync = async function (fastif // } // request.user = account } catch (err) { - return reply.send({ code: 401, msg: 'need auth' }) + return reply.send({ errcode: 401, errmsg: 'need auth' }) } } })