mirror of
https://github.com/maziggy/bambuddy.git
synced 2026-10-05 13:41:36 +02:00
Address code review feedback - fix hooks and random usage
Co-authored-by: cadtoolbox <12723486+cadtoolbox@users.noreply.github.com>
This commit is contained in:
co-authored by
cadtoolbox
parent
5462249345
commit
1a6a53d92e
@@ -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)
|
||||
|
||||
|
||||
@@ -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({
|
||||
|
||||
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user