Address code review feedback - fix hooks and random usage

Co-authored-by: cadtoolbox <12723486+cadtoolbox@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-02-08 15:34:40 +00:00
co-authored by cadtoolbox
parent 5462249345
commit 1a6a53d92e
3 changed files with 8 additions and 4 deletions
+3 -1
View File
@@ -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)
+3 -2
View File
@@ -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({
+2 -1
View File
@@ -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');