Add linkedProviders memo and include in context value

cgen-f4e79ce94d5e4e51848e88c9a514f57e
This commit is contained in:
Builder.io 2025-09-30 08:30:40 +00:00
parent c7f15318a3
commit f03a0b9c8d

View file

@ -437,6 +437,19 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({
if (user?.id) await fetchUserProfile(user.id);
};
const linkedProviders = useMemo<LinkedProvider[]>(() => {
const supported: SupportedOAuthProvider[] = ["github", "google"];
if (!user?.identities) return [];
return (user.identities as any[])
.filter((identity) => supported.includes(identity.provider))
.map((identity) => ({
provider: identity.provider as SupportedOAuthProvider,
identityId: identity.identity_id,
linkedAt: identity.created_at,
lastSignInAt: identity.last_sign_in_at,
}));
}, [user]);
const computedComplete =
checkProfileComplete(profile) ||
(typeof window !== "undefined" &&
@ -449,9 +462,12 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({
session,
loading,
profileComplete: computedComplete,
linkedProviders,
signIn,
signUp,
signInWithOAuth,
linkProvider,
unlinkProvider,
signOut,
updateProfile,
refreshProfile,