diff --git a/src/components/settings/SecurityTab.tsx b/src/components/settings/SecurityTab.tsx
index 4efd9a13..0366a333 100644
--- a/src/components/settings/SecurityTab.tsx
+++ b/src/components/settings/SecurityTab.tsx
@@ -65,10 +65,13 @@ export function SecurityTab() {
}
};
- const handleSocialLogin = async (provider: 'google') => {
+ const handleSocialLogin = async (provider: 'google' | 'discord') => {
try {
const { error } = await supabase.auth.signInWithOAuth({
- provider: provider
+ provider: provider,
+ options: {
+ redirectTo: `${window.location.origin}/settings`
+ }
});
if (error) throw error;
@@ -86,13 +89,13 @@ export function SecurityTab() {
}
};
- const handleUnlinkSocial = async (provider: 'google') => {
+ const handleUnlinkSocial = async (provider: 'google' | 'discord') => {
try {
- // Note: Supabase doesn't have a direct unlink method
- // This would typically be handled through the admin API or by the user
+ // For now, show a message that this feature requires manual action
+ // In a production app, this would typically be handled through the admin API
toast({
- title: 'Feature not available',
- description: 'Please contact support to unlink social accounts.',
+ title: `${provider.charAt(0).toUpperCase() + provider.slice(1)} Account`,
+ description: `To unlink your ${provider} account, please sign in without using ${provider} and then you can remove this connection. For assistance, contact support.`,
});
} catch (error: any) {
toast({
@@ -103,12 +106,19 @@ export function SecurityTab() {
}
};
- // Mock data for connected accounts - in real app this would come from user metadata
+ // Get connected accounts from user identities
const connectedAccounts = [
{
provider: 'google',
- connected: user?.app_metadata?.providers?.includes('google') || false,
- email: user?.email
+ connected: user?.identities?.some(identity => identity.provider === 'google') || false,
+ email: user?.identities?.find(identity => identity.provider === 'google')?.identity_data?.email || user?.email,
+ icon: '🔍'
+ },
+ {
+ provider: 'discord',
+ connected: user?.identities?.some(identity => identity.provider === 'discord') || false,
+ email: user?.identities?.find(identity => identity.provider === 'discord')?.identity_data?.email,
+ icon: '🎮'
}
];
@@ -195,14 +205,15 @@ export function SecurityTab() {
Manage your social login connections for easier access to your account.
+ To enable social providers, configure them in your Supabase Auth settings.
{connectedAccounts.map((account) => (
-
-
+
+ {account.icon}
{account.provider}
@@ -218,7 +229,7 @@ export function SecurityTab() {
@@ -227,7 +238,7 @@ export function SecurityTab() {