|
|
@@ -8,6 +8,7 @@ import { Card, CardContent, CardHeader } from './Card';
|
|
|
import { Button } from './Button';
|
|
|
import { useToast } from '../contexts/ToastContext';
|
|
|
import { useEffect } from 'react';
|
|
|
+import { useAuth } from '../contexts/AuthContext';
|
|
|
|
|
|
const SECURITY_PORT_MAP: Record<string, number> = {
|
|
|
starttls: 587,
|
|
|
@@ -25,7 +26,7 @@ export function EmailSettings() {
|
|
|
const { t } = useTranslation();
|
|
|
const { showToast } = useToast();
|
|
|
const queryClient = useQueryClient();
|
|
|
-
|
|
|
+
|
|
|
const [smtpSettings, setSMTPSettings] = useState<SMTPSettings>({
|
|
|
smtp_host: '',
|
|
|
smtp_port: 587,
|
|
|
@@ -44,6 +45,8 @@ export function EmailSettings() {
|
|
|
queryFn: () => api.getSMTPSettings(),
|
|
|
});
|
|
|
|
|
|
+ // Fetch global auth status
|
|
|
+ const { authEnabled } = useAuth();
|
|
|
// Fetch advanced auth status
|
|
|
const { data: advancedAuthStatus } = useQuery({
|
|
|
queryKey: ['advancedAuthStatus'],
|
|
|
@@ -163,6 +166,10 @@ export function EmailSettings() {
|
|
|
};
|
|
|
|
|
|
const handleToggleAdvancedAuth = () => {
|
|
|
+ if (!authEnabled) {
|
|
|
+ showToast(t('settings.email.errors.enableAuthFirst'), 'error');
|
|
|
+ return;
|
|
|
+ }
|
|
|
if (!advancedAuthStatus?.advanced_auth_enabled && !advancedAuthStatus?.smtp_configured) {
|
|
|
showToast(t('settings.email.errors.configureSmtpFirst'), 'error');
|
|
|
return;
|
|
|
@@ -251,8 +258,8 @@ export function EmailSettings() {
|
|
|
</CardContent>
|
|
|
</Card>
|
|
|
|
|
|
- {/* SMTP Configuration - dimmed when advanced auth is disabled */}
|
|
|
- <div className={!advancedEnabled ? 'opacity-50 pointer-events-none' : ''}>
|
|
|
+ {/* SMTP Configuration */}
|
|
|
+ <div>
|
|
|
<Card>
|
|
|
<CardHeader>
|
|
|
<h2 className="text-lg font-semibold text-white">
|
|
|
@@ -399,8 +406,8 @@ export function EmailSettings() {
|
|
|
</Card>
|
|
|
</div>
|
|
|
|
|
|
- {/* Test SMTP - dimmed when advanced auth is disabled */}
|
|
|
- <div className={!advancedEnabled ? 'opacity-50 pointer-events-none' : ''}>
|
|
|
+ {/* Test SMTP */}
|
|
|
+ <div>
|
|
|
<Card>
|
|
|
<CardHeader>
|
|
|
<h2 className="text-lg font-semibold text-white">
|