From 2af045979f8e014bd89ea52e341faae10db8c708 Mon Sep 17 00:00:00 2001 From: chenos Date: Tue, 12 Apr 2022 22:45:56 +0800 Subject: [PATCH] fix: no throw exception when request users:check --- packages/client/src/user/CurrentUserProvider.tsx | 2 +- packages/plugin-users/src/actions/users.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/client/src/user/CurrentUserProvider.tsx b/packages/client/src/user/CurrentUserProvider.tsx index f316be112..49403cd06 100644 --- a/packages/client/src/user/CurrentUserProvider.tsx +++ b/packages/client/src/user/CurrentUserProvider.tsx @@ -16,7 +16,7 @@ export const CurrentUserProvider = (props) => { if (result.loading) { return ; } - if (result.error) { + if (!result?.data?.data?.id) { return ; } return {props.children}; diff --git a/packages/plugin-users/src/actions/users.ts b/packages/plugin-users/src/actions/users.ts index 22e16e058..266c7961a 100644 --- a/packages/plugin-users/src/actions/users.ts +++ b/packages/plugin-users/src/actions/users.ts @@ -6,10 +6,10 @@ export async function check(ctx: Context, next: Next) { if (ctx.state.currentUser) { const user = ctx.state.currentUser.toJSON(); ctx.body = user; - await next(); } else { - ctx.throw(401, 'Unauthorized'); + ctx.body = {}; } + await next(); } export async function signin(ctx: Context, next: Next) {