Prevent unlinking final login method
cgen-84fe1c3d42ef4baeb63a696d59b58bc4
This commit is contained in:
parent
593e9f2f56
commit
d7234aed1c
1 changed files with 16 additions and 0 deletions
|
|
@ -378,6 +378,22 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const identities = (user.identities ?? []) as any[];
|
||||||
|
const supportedLinkedCount = identities.filter((item: any) =>
|
||||||
|
["github", "google"].includes(item.provider),
|
||||||
|
).length;
|
||||||
|
const hasEmailIdentity = identities.some(
|
||||||
|
(item: any) => item.provider === "email",
|
||||||
|
);
|
||||||
|
if (!hasEmailIdentity && supportedLinkedCount <= 1) {
|
||||||
|
aethexToast.error({
|
||||||
|
title: "Cannot unlink provider",
|
||||||
|
description:
|
||||||
|
"Add another sign-in method before removing this connection.",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
const { error } = (await supabase.auth.unlinkIdentity({
|
const { error } = (await supabase.auth.unlinkIdentity({
|
||||||
identity_id: identity.identity_id,
|
identity_id: identity.identity_id,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue