diff --git a/packages/blog-server/src/middleware/authMiddleware.js b/packages/blog-server/src/middleware/authMiddleware.js index 70d259ef81cdd76fbaaa69aa76cde0271fa8aaf6..3386a0d9f54250db121aaa3fd3d7ed0b22a10198 100644 --- a/packages/blog-server/src/middleware/authMiddleware.js +++ b/packages/blog-server/src/middleware/authMiddleware.js @@ -20,12 +20,20 @@ const verifyAuth = async (ctx, next) => { const userInfo = await userService.getUserById(id); ctx.userInfo = userInfo; ctx.token = authorization; - await next(); - } catch (err) { + } catch (err) { const error = new Error(`Permission failed~`); error.status = 401; throw error } + try { + await next(); + } catch (error) { + const error = new Error(`Client error~`); + error.status = 400; + throw error + } + + } module.exports = {