From 0c6df6da1e5afc25846da24ed2ad9d7d409c5723 Mon Sep 17 00:00:00 2001 From: xuqssq Date: Sun, 29 Dec 2024 18:14:49 +0800 Subject: [PATCH] fix --- src/contexts/AuthContext.jsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/contexts/AuthContext.jsx b/src/contexts/AuthContext.jsx index 67de834..8c84f5b 100644 --- a/src/contexts/AuthContext.jsx +++ b/src/contexts/AuthContext.jsx @@ -39,7 +39,6 @@ export const AuthProvider = ({ children }) => { data: { session }, error, } = await supabase.auth.getSession(); - const role = await checkInTeam(session?.user ?? null); setUser({ ...session?.user, adminRole: role }); } catch (error) { @@ -52,6 +51,15 @@ export const AuthProvider = ({ children }) => { initSession(); }, []); + useEffect(() => { + if (user?.id && !user?.adminRole) { + (async () => { + const role = await checkInTeam(user); + setUser({ ...user, adminRole: role }); + })(); + } + }, [user]); + // useEffect(() => { // const redirectTo = searchParams.get("redirectTo"); // if (redirectTo) {