Add refreshAuthState helper
cgen-e4d771c7539c42949278bdaa19da2ef8
This commit is contained in:
parent
dd70e2130d
commit
3217432b3b
1 changed files with 10 additions and 0 deletions
|
|
@ -212,6 +212,16 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({
|
|||
}
|
||||
};
|
||||
|
||||
const refreshAuthState = useCallback(async () => {
|
||||
try {
|
||||
const { data } = await supabase.auth.getSession();
|
||||
setSession(data.session);
|
||||
setUser(data.session?.user ?? null);
|
||||
} catch (error) {
|
||||
console.warn("Failed to refresh auth state:", error);
|
||||
}
|
||||
}, []);
|
||||
|
||||
const signIn = async (email: string, password: string) => {
|
||||
setLoading(true);
|
||||
try {
|
||||
|
|
|
|||
Loading…
Reference in a new issue