Add linkedProviders memo and include in context value
cgen-f4e79ce94d5e4e51848e88c9a514f57e
This commit is contained in:
parent
c7f15318a3
commit
f03a0b9c8d
1 changed files with 16 additions and 0 deletions
|
|
@ -437,6 +437,19 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({
|
||||||
if (user?.id) await fetchUserProfile(user.id);
|
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 =
|
const computedComplete =
|
||||||
checkProfileComplete(profile) ||
|
checkProfileComplete(profile) ||
|
||||||
(typeof window !== "undefined" &&
|
(typeof window !== "undefined" &&
|
||||||
|
|
@ -449,9 +462,12 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({
|
||||||
session,
|
session,
|
||||||
loading,
|
loading,
|
||||||
profileComplete: computedComplete,
|
profileComplete: computedComplete,
|
||||||
|
linkedProviders,
|
||||||
signIn,
|
signIn,
|
||||||
signUp,
|
signUp,
|
||||||
signInWithOAuth,
|
signInWithOAuth,
|
||||||
|
linkProvider,
|
||||||
|
unlinkProvider,
|
||||||
signOut,
|
signOut,
|
||||||
updateProfile,
|
updateProfile,
|
||||||
refreshProfile,
|
refreshProfile,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue