fix: no throw exception when request users:check
This commit is contained in:
parent
d7856e76ab
commit
2af045979f
@ -16,7 +16,7 @@ export const CurrentUserProvider = (props) => {
|
||||
if (result.loading) {
|
||||
return <Spin />;
|
||||
}
|
||||
if (result.error) {
|
||||
if (!result?.data?.data?.id) {
|
||||
return <Redirect to={'/signin'} />;
|
||||
}
|
||||
return <CurrentUserContext.Provider value={result}>{props.children}</CurrentUserContext.Provider>;
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user