From e65282dcc52abcae6a2b3d56d481b28afb9868f4 Mon Sep 17 00:00:00 2001 From: Steven Date: Fri, 15 Sep 2023 09:10:16 +0800 Subject: [PATCH] chore: fix user state loader --- api/v1/jwt.go | 2 -- web/src/router/index.tsx | 10 ++++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/api/v1/jwt.go b/api/v1/jwt.go index 2af4b91f..29b423d1 100644 --- a/api/v1/jwt.go +++ b/api/v1/jwt.go @@ -67,8 +67,6 @@ func JWTMiddleware(server *APIV1Service, next echo.HandlerFunc, secret string) e return next(c) } - println("path", path) - // Skip validation for server status endpoints. if util.HasPrefixes(path, "/api/v1/ping", "/api/v1/idp", "/api/v1/status", "/api/v1/user") && path != "/api/v1/user/me" && method == http.MethodGet { return next(c) diff --git a/web/src/router/index.tsx b/web/src/router/index.tsx index b8f3d3c2..5504d122 100644 --- a/web/src/router/index.tsx +++ b/web/src/router/index.tsx @@ -34,14 +34,16 @@ const initialGlobalStateLoader = (() => { })(); const userStateLoader = async () => { + let user = undefined; try { - const user = await initialUserState(); - if (!user) { - return redirect("/explore"); - } + user = await initialUserState(); } catch (error) { // do nothing. } + + if (!user) { + return redirect("/explore"); + } return null; };