From b72d99449efe38d7c33546f9c3113851a3ce975e Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Sun, 28 Sep 2025 20:44:01 +0000 Subject: [PATCH] Visual edit in Lovable --- src/components/settings/SecurityTab.tsx | 138 ++++++++---------------- 1 file changed, 44 insertions(+), 94 deletions(-) diff --git a/src/components/settings/SecurityTab.tsx b/src/components/settings/SecurityTab.tsx index 2fab34fe..913a6808 100644 --- a/src/components/settings/SecurityTab.tsx +++ b/src/components/settings/SecurityTab.tsx @@ -15,23 +15,23 @@ import { Shield, Key, Smartphone, Globe, ExternalLink } from 'lucide-react'; import { TOTPSetup } from '@/components/auth/TOTPSetup'; import { GoogleIcon } from '@/components/icons/GoogleIcon'; import { DiscordIcon } from '@/components/icons/DiscordIcon'; - const passwordSchema = z.object({ currentPassword: z.string().min(1, 'Current password is required'), newPassword: z.string().min(8, 'Password must be at least 8 characters'), confirmPassword: z.string() -}).refine((data) => data.newPassword === data.confirmPassword, { +}).refine(data => data.newPassword === data.confirmPassword, { message: "Passwords don't match", path: ["confirmPassword"] }); - type PasswordFormData = z.infer; - export function SecurityTab() { - const { user } = useAuth(); - const { toast } = useToast(); + const { + user + } = useAuth(); + const { + toast + } = useToast(); const [loading, setLoading] = useState(false); - const form = useForm({ resolver: zodResolver(passwordSchema), defaultValues: { @@ -40,18 +40,16 @@ export function SecurityTab() { confirmPassword: '' } }); - const onSubmit = async (data: PasswordFormData) => { if (!user) return; - setLoading(true); try { - const { error } = await supabase.auth.updateUser({ + const { + error + } = await supabase.auth.updateUser({ password: data.newPassword }); - if (error) throw error; - form.reset(); toast({ title: 'Password updated', @@ -67,18 +65,17 @@ export function SecurityTab() { setLoading(false); } }; - const handleSocialLogin = async (provider: 'google' | 'discord') => { try { - const { error } = await supabase.auth.signInWithOAuth({ + const { + error + } = await supabase.auth.signInWithOAuth({ provider: provider, options: { redirectTo: `${window.location.origin}/settings` } }); - if (error) throw error; - toast({ title: 'Redirecting...', description: `Redirecting to ${provider} to link your account.` @@ -91,14 +88,13 @@ export function SecurityTab() { }); } }; - const handleUnlinkSocial = async (provider: 'google' | 'discord') => { try { // 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: `${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.`, + 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({ @@ -110,23 +106,18 @@ export function SecurityTab() { }; // Get connected accounts from user identities - const connectedAccounts = [ - { - provider: 'google', - 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: - } - ]; - - return ( -
+ const connectedAccounts = [{ + provider: 'google', + 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: + }]; + return
{/* Change Password */}
@@ -144,47 +135,26 @@ export function SecurityTab() {
- - {form.formState.errors.currentPassword && ( -

+ + {form.formState.errors.currentPassword &&

{form.formState.errors.currentPassword.message} -

- )} +

}
- - {form.formState.errors.newPassword && ( -

+ + {form.formState.errors.newPassword &&

{form.formState.errors.newPassword.message} -

- )} +

}
- - {form.formState.errors.confirmPassword && ( -

+ + {form.formState.errors.confirmPassword &&

{form.formState.errors.confirmPassword.message} -

- )} +

}
- - ) : ( - - )} + }
-
- ))} +
)}
@@ -257,10 +211,7 @@ export function SecurityTab() { {/* Two-Factor Authentication */}
-
- -

Two-Factor Authentication

-
+ {/* Two-Factor Authentication */}
@@ -307,6 +258,5 @@ export function SecurityTab() {
-
- ); + ; } \ No newline at end of file