diff --git a/backend/app/services/email_service.py b/backend/app/services/email_service.py index 3daec577f..3f01938f4 100644 --- a/backend/app/services/email_service.py +++ b/backend/app/services/email_service.py @@ -30,6 +30,8 @@ def generate_secure_password(length: int = 16) -> str: Returns: A secure random password containing uppercase, lowercase, digits, and special characters """ + import random + # Define character sets lowercase = string.ascii_lowercase uppercase = string.ascii_uppercase @@ -49,7 +51,7 @@ def generate_secure_password(length: int = 16) -> str: password_chars.extend(secrets.choice(all_chars) for _ in range(length - 4)) # Shuffle to avoid predictable patterns - secrets.SystemRandom().shuffle(password_chars) + random.shuffle(password_chars) return "".join(password_chars) diff --git a/frontend/src/components/EmailSettings.tsx b/frontend/src/components/EmailSettings.tsx index 02f8a4ba2..1c557ea96 100644 --- a/frontend/src/components/EmailSettings.tsx +++ b/frontend/src/components/EmailSettings.tsx @@ -7,6 +7,7 @@ import type { SMTPSettings, TestSMTPRequest } from '../api/client'; import { Card, CardContent, CardHeader } from './Card'; import { Button } from './Button'; import { useToast } from '../contexts/ToastContext'; +import { useEffect } from 'react'; export function EmailSettings() { const { t } = useTranslation(); @@ -37,14 +38,14 @@ export function EmailSettings() { }); // Load existing settings when fetched - useState(() => { + useEffect(() => { if (existingSettings) { setSMTPSettings({ ...existingSettings, smtp_password: '', // Never show password }); } - }); + }, [existingSettings]); // Save SMTP settings const saveMutation = useMutation({ diff --git a/frontend/src/pages/UsersPage.tsx b/frontend/src/pages/UsersPage.tsx index 0a8a10cfd..2ac6b4ab8 100644 --- a/frontend/src/pages/UsersPage.tsx +++ b/frontend/src/pages/UsersPage.tsx @@ -124,7 +124,8 @@ export function UsersPage() { }); const handleCreate = () => { - const advancedAuthEnabled = advancedAuthStatus?.advanced_auth_enabled; + // Use the status from the query hook + const advancedAuthEnabled = advancedAuthStatus?.advanced_auth_enabled || false; if (!formData.username) { showToast(t('users.toast.fillRequired'), 'error');