mirror of
https://github.com/maziggy/bambuddy.git
synced 2026-10-09 07:25:44 +02:00
Merge pull request #16 from cadtoolbox/copilot/update-global-email-settings
Update Global Email settings to match notification email provider fields
This commit is contained in:
@@ -351,7 +351,8 @@ async def test_smtp_connection(
|
||||
smtp_port=test_request.smtp_port,
|
||||
smtp_username=test_request.smtp_username,
|
||||
smtp_password=test_request.smtp_password,
|
||||
smtp_use_tls=test_request.smtp_use_tls,
|
||||
smtp_security=test_request.smtp_security,
|
||||
smtp_auth_enabled=test_request.smtp_auth_enabled,
|
||||
smtp_from_email=test_request.smtp_from_email,
|
||||
)
|
||||
|
||||
|
||||
@@ -89,21 +89,27 @@ class ResetPasswordResponse(BaseModel):
|
||||
class SMTPSettings(BaseModel):
|
||||
smtp_host: str
|
||||
smtp_port: int
|
||||
smtp_username: str
|
||||
smtp_password: str | None = None # Optional for read operations
|
||||
smtp_use_tls: bool = True
|
||||
smtp_username: str | None = None # Optional when auth is disabled
|
||||
smtp_password: str | None = None # Optional for read operations or when auth is disabled
|
||||
smtp_security: str = "starttls" # 'starttls', 'ssl', 'none'
|
||||
smtp_auth_enabled: bool = True
|
||||
smtp_from_email: str
|
||||
smtp_from_name: str = "BamBuddy"
|
||||
# Deprecated field for backward compatibility
|
||||
smtp_use_tls: bool | None = None
|
||||
|
||||
|
||||
class TestSMTPRequest(BaseModel):
|
||||
smtp_host: str
|
||||
smtp_port: int
|
||||
smtp_username: str
|
||||
smtp_password: str
|
||||
smtp_use_tls: bool = True
|
||||
smtp_username: str | None = None # Optional when auth is disabled
|
||||
smtp_password: str | None = None # Optional when auth is disabled
|
||||
smtp_security: str = "starttls" # 'starttls', 'ssl', 'none'
|
||||
smtp_auth_enabled: bool = True
|
||||
smtp_from_email: str
|
||||
test_recipient: str
|
||||
# Deprecated field for backward compatibility
|
||||
smtp_use_tls: bool | None = None
|
||||
|
||||
|
||||
class TestSMTPResponse(BaseModel):
|
||||
|
||||
@@ -71,6 +71,8 @@ async def get_smtp_settings(db: AsyncSession) -> SMTPSettings | None:
|
||||
"smtp_username",
|
||||
"smtp_password",
|
||||
"smtp_use_tls",
|
||||
"smtp_security",
|
||||
"smtp_auth_enabled",
|
||||
"smtp_from_email",
|
||||
"smtp_from_name",
|
||||
])
|
||||
@@ -79,16 +81,26 @@ async def get_smtp_settings(db: AsyncSession) -> SMTPSettings | None:
|
||||
settings_dict = {s.key: s.value for s in result.scalars().all()}
|
||||
|
||||
# Check if minimum required settings are present
|
||||
required_keys = ["smtp_host", "smtp_port", "smtp_username", "smtp_from_email"]
|
||||
required_keys = ["smtp_host", "smtp_port", "smtp_from_email"]
|
||||
if not all(key in settings_dict for key in required_keys):
|
||||
return None
|
||||
|
||||
# Handle migration: convert old smtp_use_tls to smtp_security if needed
|
||||
smtp_security = settings_dict.get("smtp_security")
|
||||
if not smtp_security:
|
||||
# Migrate from old smtp_use_tls format
|
||||
smtp_use_tls = settings_dict.get("smtp_use_tls", "true").lower() == "true"
|
||||
smtp_security = "starttls" if smtp_use_tls else "ssl"
|
||||
|
||||
smtp_auth_enabled = settings_dict.get("smtp_auth_enabled", "true").lower() == "true"
|
||||
|
||||
return SMTPSettings(
|
||||
smtp_host=settings_dict["smtp_host"],
|
||||
smtp_port=int(settings_dict["smtp_port"]),
|
||||
smtp_username=settings_dict["smtp_username"],
|
||||
smtp_username=settings_dict.get("smtp_username"),
|
||||
smtp_password=settings_dict.get("smtp_password"),
|
||||
smtp_use_tls=settings_dict.get("smtp_use_tls", "true").lower() == "true",
|
||||
smtp_security=smtp_security,
|
||||
smtp_auth_enabled=smtp_auth_enabled,
|
||||
smtp_from_email=settings_dict["smtp_from_email"],
|
||||
smtp_from_name=settings_dict.get("smtp_from_name", "BamBuddy"),
|
||||
)
|
||||
@@ -107,12 +119,16 @@ async def save_smtp_settings(db: AsyncSession, smtp_settings: SMTPSettings) -> N
|
||||
settings_data = {
|
||||
"smtp_host": smtp_settings.smtp_host,
|
||||
"smtp_port": str(smtp_settings.smtp_port),
|
||||
"smtp_username": smtp_settings.smtp_username,
|
||||
"smtp_use_tls": "true" if smtp_settings.smtp_use_tls else "false",
|
||||
"smtp_security": smtp_settings.smtp_security,
|
||||
"smtp_auth_enabled": "true" if smtp_settings.smtp_auth_enabled else "false",
|
||||
"smtp_from_email": smtp_settings.smtp_from_email,
|
||||
"smtp_from_name": smtp_settings.smtp_from_name,
|
||||
}
|
||||
|
||||
# Only save username if auth is enabled or if provided
|
||||
if smtp_settings.smtp_username:
|
||||
settings_data["smtp_username"] = smtp_settings.smtp_username
|
||||
|
||||
# Only save password if provided
|
||||
if smtp_settings.smtp_password:
|
||||
settings_data["smtp_password"] = smtp_settings.smtp_password
|
||||
@@ -159,17 +175,31 @@ def send_email(
|
||||
|
||||
# Send email
|
||||
try:
|
||||
if smtp_settings.smtp_use_tls:
|
||||
# Use TLS (port 587 typically)
|
||||
security = smtp_settings.smtp_security
|
||||
auth_enabled = smtp_settings.smtp_auth_enabled
|
||||
|
||||
# Validate username is provided when authentication is enabled
|
||||
if auth_enabled and smtp_settings.smtp_password:
|
||||
if not smtp_settings.smtp_username:
|
||||
raise ValueError("SMTP username is required when authentication is enabled")
|
||||
|
||||
if security == "ssl":
|
||||
# Direct SSL connection (typically port 465)
|
||||
with smtplib.SMTP_SSL(smtp_settings.smtp_host, smtp_settings.smtp_port, timeout=10) as server:
|
||||
if auth_enabled and smtp_settings.smtp_password and smtp_settings.smtp_username:
|
||||
server.login(smtp_settings.smtp_username, smtp_settings.smtp_password)
|
||||
server.send_message(msg)
|
||||
elif security == "starttls":
|
||||
# STARTTLS upgrade (typically port 587)
|
||||
with smtplib.SMTP(smtp_settings.smtp_host, smtp_settings.smtp_port, timeout=10) as server:
|
||||
server.starttls()
|
||||
if smtp_settings.smtp_password:
|
||||
if auth_enabled and smtp_settings.smtp_password and smtp_settings.smtp_username:
|
||||
server.login(smtp_settings.smtp_username, smtp_settings.smtp_password)
|
||||
server.send_message(msg)
|
||||
else:
|
||||
# Use SSL (port 465 typically) or no encryption
|
||||
with smtplib.SMTP_SSL(smtp_settings.smtp_host, smtp_settings.smtp_port, timeout=10) as server:
|
||||
if smtp_settings.smtp_password:
|
||||
# No encryption (typically port 25) - use with caution
|
||||
with smtplib.SMTP(smtp_settings.smtp_host, smtp_settings.smtp_port, timeout=10) as server:
|
||||
if auth_enabled and smtp_settings.smtp_password and smtp_settings.smtp_username:
|
||||
server.login(smtp_settings.smtp_username, smtp_settings.smtp_password)
|
||||
server.send_message(msg)
|
||||
logger.info(f"Email sent successfully to {to_email}")
|
||||
|
||||
Generated
+1161
-988
File diff suppressed because it is too large
Load Diff
@@ -1894,9 +1894,10 @@ export interface ResetPasswordResponse {
|
||||
export interface SMTPSettings {
|
||||
smtp_host: string;
|
||||
smtp_port: number;
|
||||
smtp_username: string;
|
||||
smtp_username?: string;
|
||||
smtp_password?: string;
|
||||
smtp_use_tls: boolean;
|
||||
smtp_security: 'starttls' | 'ssl' | 'none';
|
||||
smtp_auth_enabled: boolean;
|
||||
smtp_from_email: string;
|
||||
smtp_from_name: string;
|
||||
}
|
||||
@@ -1904,9 +1905,10 @@ export interface SMTPSettings {
|
||||
export interface TestSMTPRequest {
|
||||
smtp_host: string;
|
||||
smtp_port: number;
|
||||
smtp_username: string;
|
||||
smtp_password: string;
|
||||
smtp_use_tls: boolean;
|
||||
smtp_username?: string;
|
||||
smtp_password?: string;
|
||||
smtp_security: 'starttls' | 'ssl' | 'none';
|
||||
smtp_auth_enabled: boolean;
|
||||
smtp_from_email: string;
|
||||
test_recipient: string;
|
||||
}
|
||||
|
||||
@@ -19,7 +19,8 @@ export function EmailSettings() {
|
||||
smtp_port: 587,
|
||||
smtp_username: '',
|
||||
smtp_password: '',
|
||||
smtp_use_tls: true,
|
||||
smtp_security: 'starttls',
|
||||
smtp_auth_enabled: true,
|
||||
smtp_from_email: '',
|
||||
smtp_from_name: 'BamBuddy',
|
||||
});
|
||||
@@ -86,10 +87,15 @@ export function EmailSettings() {
|
||||
|
||||
const handleSave = () => {
|
||||
// Validate required fields
|
||||
if (!smtpSettings.smtp_host || !smtpSettings.smtp_username || !smtpSettings.smtp_from_email) {
|
||||
if (!smtpSettings.smtp_host || !smtpSettings.smtp_from_email) {
|
||||
showToast('Please fill in all required fields', 'error');
|
||||
return;
|
||||
}
|
||||
// Validate auth fields when authentication is enabled
|
||||
if (smtpSettings.smtp_auth_enabled && (!smtpSettings.smtp_username)) {
|
||||
showToast('Username is required when authentication is enabled', 'error');
|
||||
return;
|
||||
}
|
||||
saveMutation.mutate(smtpSettings);
|
||||
};
|
||||
|
||||
@@ -98,8 +104,13 @@ export function EmailSettings() {
|
||||
showToast('Please enter a test email address', 'error');
|
||||
return;
|
||||
}
|
||||
if (!smtpSettings.smtp_host || !smtpSettings.smtp_username || !smtpSettings.smtp_password || !smtpSettings.smtp_from_email) {
|
||||
showToast('Please fill in all SMTP settings before testing', 'error');
|
||||
if (!smtpSettings.smtp_host || !smtpSettings.smtp_from_email) {
|
||||
showToast('Please fill in SMTP Server and From Email before testing', 'error');
|
||||
return;
|
||||
}
|
||||
// Validate auth fields when authentication is enabled
|
||||
if (smtpSettings.smtp_auth_enabled && (!smtpSettings.smtp_username || !smtpSettings.smtp_password)) {
|
||||
showToast('Username and Password are required when authentication is enabled', 'error');
|
||||
return;
|
||||
}
|
||||
testMutation.mutate({
|
||||
@@ -107,7 +118,8 @@ export function EmailSettings() {
|
||||
smtp_port: smtpSettings.smtp_port,
|
||||
smtp_username: smtpSettings.smtp_username,
|
||||
smtp_password: smtpSettings.smtp_password,
|
||||
smtp_use_tls: smtpSettings.smtp_use_tls,
|
||||
smtp_security: smtpSettings.smtp_security,
|
||||
smtp_auth_enabled: smtpSettings.smtp_auth_enabled,
|
||||
smtp_from_email: smtpSettings.smtp_from_email,
|
||||
test_recipient: testEmail,
|
||||
});
|
||||
@@ -131,73 +143,6 @@ export function EmailSettings() {
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
{/* Advanced Authentication Toggle */}
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="flex items-center gap-2">
|
||||
<Mail className="w-5 h-5 text-bambu-green" />
|
||||
<h2 className="text-lg font-semibold text-white">
|
||||
{t('settings.email.advancedAuth') || 'Advanced Authentication'}
|
||||
</h2>
|
||||
</div>
|
||||
<Button
|
||||
onClick={handleToggleAdvancedAuth}
|
||||
disabled={toggleAdvancedAuthMutation.isPending}
|
||||
variant={advancedAuthStatus?.advanced_auth_enabled ? 'danger' : 'primary'}
|
||||
>
|
||||
{advancedAuthStatus?.advanced_auth_enabled ? (
|
||||
<>
|
||||
<Unlock className="w-4 h-4" />
|
||||
{t('settings.email.disable') || 'Disable'}
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<Lock className="w-4 h-4" />
|
||||
{t('settings.email.enable') || 'Enable'}
|
||||
</>
|
||||
)}
|
||||
</Button>
|
||||
</div>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<div className="space-y-4">
|
||||
{advancedAuthStatus?.advanced_auth_enabled ? (
|
||||
<div className="bg-green-500/10 border border-green-500/30 rounded-lg p-4">
|
||||
<div className="flex items-start gap-3">
|
||||
<CheckCircle className="w-5 h-5 text-green-400 mt-0.5 flex-shrink-0" />
|
||||
<div className="space-y-2">
|
||||
<p className="text-white font-medium">
|
||||
{t('settings.email.advancedAuthEnabled') || 'Advanced Authentication is enabled'}
|
||||
</p>
|
||||
<ul className="text-sm text-green-300 space-y-1 list-disc list-inside">
|
||||
<li>{t('settings.email.feature1') || 'Passwords are auto-generated and emailed to new users'}</li>
|
||||
<li>{t('settings.email.feature2') || 'Users can login with username or email'}</li>
|
||||
<li>{t('settings.email.feature3') || 'Forgot password feature is available'}</li>
|
||||
<li>{t('settings.email.feature4') || 'Admins can reset user passwords via email'}</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<div className="bg-yellow-500/10 border border-yellow-500/30 rounded-lg p-4">
|
||||
<div className="flex items-start gap-3">
|
||||
<AlertTriangle className="w-5 h-5 text-yellow-400 mt-0.5 flex-shrink-0" />
|
||||
<div className="space-y-2">
|
||||
<p className="text-white font-medium">
|
||||
{t('settings.email.advancedAuthDisabled') || 'Advanced Authentication is disabled'}
|
||||
</p>
|
||||
<p className="text-sm text-yellow-300">
|
||||
{t('settings.email.advancedAuthDisabledDesc') || 'Configure and test SMTP settings below, then enable advanced authentication to activate email-based features.'}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
{/* SMTP Configuration */}
|
||||
<Card>
|
||||
<CardHeader>
|
||||
@@ -222,42 +167,77 @@ export function EmailSettings() {
|
||||
</div>
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-white mb-2">
|
||||
{t('settings.email.smtpPort') || 'Port'} *
|
||||
{t('settings.email.smtpPort') || 'SMTP Port'}
|
||||
</label>
|
||||
<input
|
||||
type="number"
|
||||
value={smtpSettings.smtp_port}
|
||||
onChange={(e) => setSMTPSettings({ ...smtpSettings, smtp_port: parseInt(e.target.value) || 587 })}
|
||||
placeholder="587"
|
||||
className="w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-white mb-2">
|
||||
{t('settings.email.username') || 'Username'} *
|
||||
</label>
|
||||
<input
|
||||
type="text"
|
||||
value={smtpSettings.smtp_username}
|
||||
onChange={(e) => setSMTPSettings({ ...smtpSettings, smtp_username: e.target.value })}
|
||||
placeholder="your.email@gmail.com"
|
||||
className="w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors"
|
||||
/>
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-white mb-2">
|
||||
{t('settings.email.security') || 'Security'}
|
||||
</label>
|
||||
<select
|
||||
value={smtpSettings.smtp_security}
|
||||
onChange={(e) => setSMTPSettings({ ...smtpSettings, smtp_security: e.target.value as 'starttls' | 'ssl' | 'none' })}
|
||||
className="w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors"
|
||||
>
|
||||
<option value="starttls">STARTTLS (Port 587)</option>
|
||||
<option value="ssl">SSL/TLS (Port 465)</option>
|
||||
<option value="none">None (Port 25)</option>
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-white mb-2">
|
||||
{t('settings.email.authentication') || 'Authentication'}
|
||||
</label>
|
||||
<select
|
||||
value={smtpSettings.smtp_auth_enabled ? 'true' : 'false'}
|
||||
onChange={(e) => setSMTPSettings({ ...smtpSettings, smtp_auth_enabled: e.target.value === 'true' })}
|
||||
className="w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors"
|
||||
>
|
||||
<option value="true">Enabled</option>
|
||||
<option value="false">Disabled</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-white mb-2">
|
||||
{t('settings.email.password') || 'Password'} *
|
||||
</label>
|
||||
<input
|
||||
type="password"
|
||||
value={smtpSettings.smtp_password}
|
||||
onChange={(e) => setSMTPSettings({ ...smtpSettings, smtp_password: e.target.value })}
|
||||
placeholder={existingSettings ? '••••••••' : 'Enter password'}
|
||||
className="w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors"
|
||||
/>
|
||||
</div>
|
||||
{smtpSettings.smtp_auth_enabled && (
|
||||
<>
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-white mb-2">
|
||||
{t('settings.email.username') || 'Username'}
|
||||
</label>
|
||||
<input
|
||||
type="text"
|
||||
value={smtpSettings.smtp_username || ''}
|
||||
onChange={(e) => setSMTPSettings({ ...smtpSettings, smtp_username: e.target.value })}
|
||||
placeholder="your.email@gmail.com"
|
||||
className="w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-white mb-2">
|
||||
{t('settings.email.password') || 'Password'}
|
||||
</label>
|
||||
<input
|
||||
type="password"
|
||||
value={smtpSettings.smtp_password || ''}
|
||||
onChange={(e) => setSMTPSettings({ ...smtpSettings, smtp_password: e.target.value })}
|
||||
placeholder={existingSettings ? '••••••••' : 'App password'}
|
||||
className="w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors"
|
||||
/>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<div>
|
||||
@@ -268,7 +248,7 @@ export function EmailSettings() {
|
||||
type="email"
|
||||
value={smtpSettings.smtp_from_email}
|
||||
onChange={(e) => setSMTPSettings({ ...smtpSettings, smtp_from_email: e.target.value })}
|
||||
placeholder="noreply@yourdomain.com"
|
||||
placeholder="your@email.com"
|
||||
className="w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors"
|
||||
/>
|
||||
</div>
|
||||
@@ -286,19 +266,6 @@ export function EmailSettings() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center gap-2">
|
||||
<input
|
||||
type="checkbox"
|
||||
id="use_tls"
|
||||
checked={smtpSettings.smtp_use_tls}
|
||||
onChange={(e) => setSMTPSettings({ ...smtpSettings, smtp_use_tls: e.target.checked })}
|
||||
className="w-4 h-4 rounded border-bambu-gray text-bambu-green focus:ring-bambu-green focus:ring-offset-0 bg-bambu-dark"
|
||||
/>
|
||||
<label htmlFor="use_tls" className="text-sm text-white">
|
||||
{t('settings.email.useTLS') || 'Use TLS (recommended)'}
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div className="flex gap-2">
|
||||
<Button
|
||||
onClick={handleSave}
|
||||
@@ -360,6 +327,75 @@ export function EmailSettings() {
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
{/* Advanced Authentication Toggle - Only show when SMTP is configured */}
|
||||
{advancedAuthStatus?.smtp_configured && (
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="flex items-center gap-2">
|
||||
<Mail className="w-5 h-5 text-bambu-green" />
|
||||
<h2 className="text-lg font-semibold text-white">
|
||||
{t('settings.email.advancedAuth') || 'Advanced Authentication'}
|
||||
</h2>
|
||||
</div>
|
||||
<Button
|
||||
onClick={handleToggleAdvancedAuth}
|
||||
disabled={toggleAdvancedAuthMutation.isPending}
|
||||
variant={advancedAuthStatus?.advanced_auth_enabled ? 'danger' : 'primary'}
|
||||
>
|
||||
{advancedAuthStatus?.advanced_auth_enabled ? (
|
||||
<>
|
||||
<Unlock className="w-4 h-4" />
|
||||
{t('settings.email.disable') || 'Disable'}
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<Lock className="w-4 h-4" />
|
||||
{t('settings.email.enable') || 'Enable'}
|
||||
</>
|
||||
)}
|
||||
</Button>
|
||||
</div>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<div className="space-y-4">
|
||||
{advancedAuthStatus?.advanced_auth_enabled ? (
|
||||
<div className="bg-green-500/10 border border-green-500/30 rounded-lg p-4">
|
||||
<div className="flex items-start gap-3">
|
||||
<CheckCircle className="w-5 h-5 text-green-400 mt-0.5 flex-shrink-0" />
|
||||
<div className="space-y-2">
|
||||
<p className="text-white font-medium">
|
||||
{t('settings.email.advancedAuthEnabled') || 'Advanced Authentication is enabled'}
|
||||
</p>
|
||||
<ul className="text-sm text-green-300 space-y-1 list-disc list-inside">
|
||||
<li>{t('settings.email.feature1') || 'Passwords are auto-generated and emailed to new users'}</li>
|
||||
<li>{t('settings.email.feature2') || 'Users can login with username or email'}</li>
|
||||
<li>{t('settings.email.feature3') || 'Forgot password feature is available'}</li>
|
||||
<li>{t('settings.email.feature4') || 'Admins can reset user passwords via email'}</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<div className="bg-yellow-500/10 border border-yellow-500/30 rounded-lg p-4">
|
||||
<div className="flex items-start gap-3">
|
||||
<AlertTriangle className="w-5 h-5 text-yellow-400 mt-0.5 flex-shrink-0" />
|
||||
<div className="space-y-2">
|
||||
<p className="text-white font-medium">
|
||||
{t('settings.email.advancedAuthDisabled') || 'Advanced Authentication is disabled'}
|
||||
</p>
|
||||
<p className="text-sm text-yellow-300">
|
||||
{t('settings.email.advancedAuthDisabledDesc') || 'Enable advanced authentication to activate email-based features for user management.'}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1000,6 +1000,35 @@ export default {
|
||||
virtualPrinter: 'Virtueller Drucker',
|
||||
users: 'Benutzer',
|
||||
backup: 'Sicherung',
|
||||
globalEmail: 'Globale E-Mail',
|
||||
},
|
||||
// Email settings
|
||||
email: {
|
||||
smtpSettings: 'SMTP-Konfiguration',
|
||||
smtpHost: 'SMTP-Server',
|
||||
smtpPort: 'SMTP-Port',
|
||||
security: 'Sicherheit',
|
||||
authentication: 'Authentifizierung',
|
||||
username: 'Benutzername',
|
||||
password: 'Passwort',
|
||||
fromEmail: 'Absender-E-Mail',
|
||||
fromName: 'Absendername',
|
||||
testConnection: 'SMTP-Verbindung testen',
|
||||
testRecipient: 'Test-Empfänger-E-Mail',
|
||||
sendTest: 'Test-E-Mail senden',
|
||||
sending: 'Wird gesendet...',
|
||||
save: 'Einstellungen speichern',
|
||||
saving: 'Wird gespeichert...',
|
||||
advancedAuth: 'Erweiterte Authentifizierung',
|
||||
advancedAuthEnabled: 'Erweiterte Authentifizierung ist aktiviert',
|
||||
advancedAuthDisabled: 'Erweiterte Authentifizierung ist deaktiviert',
|
||||
advancedAuthDisabledDesc: 'Aktivieren Sie die erweiterte Authentifizierung, um E-Mail-basierte Funktionen für die Benutzerverwaltung zu aktivieren.',
|
||||
enable: 'Aktivieren',
|
||||
disable: 'Deaktivieren',
|
||||
feature1: 'Passwörter werden automatisch generiert und an neue Benutzer gesendet',
|
||||
feature2: 'Benutzer können sich mit Benutzername oder E-Mail anmelden',
|
||||
feature3: 'Passwort vergessen Funktion ist verfügbar',
|
||||
feature4: 'Administratoren können Benutzerpasswörter per E-Mail zurücksetzen',
|
||||
},
|
||||
appearance: 'Erscheinungsbild',
|
||||
notifications: 'Benachrichtigungen',
|
||||
|
||||
@@ -1000,6 +1000,35 @@ export default {
|
||||
virtualPrinter: 'Virtual Printer',
|
||||
users: 'Users',
|
||||
backup: 'Backup',
|
||||
globalEmail: 'Global Email',
|
||||
},
|
||||
// Email settings
|
||||
email: {
|
||||
smtpSettings: 'SMTP Configuration',
|
||||
smtpHost: 'SMTP Server',
|
||||
smtpPort: 'SMTP Port',
|
||||
security: 'Security',
|
||||
authentication: 'Authentication',
|
||||
username: 'Username',
|
||||
password: 'Password',
|
||||
fromEmail: 'From Email',
|
||||
fromName: 'From Name',
|
||||
testConnection: 'Test SMTP Connection',
|
||||
testRecipient: 'Test Recipient Email',
|
||||
sendTest: 'Send Test Email',
|
||||
sending: 'Sending...',
|
||||
save: 'Save Settings',
|
||||
saving: 'Saving...',
|
||||
advancedAuth: 'Advanced Authentication',
|
||||
advancedAuthEnabled: 'Advanced Authentication is enabled',
|
||||
advancedAuthDisabled: 'Advanced Authentication is disabled',
|
||||
advancedAuthDisabledDesc: 'Enable advanced authentication to activate email-based features for user management.',
|
||||
enable: 'Enable',
|
||||
disable: 'Disable',
|
||||
feature1: 'Passwords are auto-generated and emailed to new users',
|
||||
feature2: 'Users can login with username or email',
|
||||
feature3: 'Forgot password feature is available',
|
||||
feature4: 'Admins can reset user passwords via email',
|
||||
},
|
||||
appearance: 'Appearance',
|
||||
notifications: 'Notifications',
|
||||
|
||||
@@ -1139,6 +1139,49 @@ export default {
|
||||
tabApiKeys: 'APIキー',
|
||||
tabVirtualPrinter: '仮想プリンター',
|
||||
tabUsers: 'ユーザー',
|
||||
tabGlobalEmail: 'グローバルメール',
|
||||
tabBackup: 'バックアップ',
|
||||
// Settings tabs object (for consistency with other locales)
|
||||
tabs: {
|
||||
general: '一般',
|
||||
smartPlugs: 'スマートプラグ',
|
||||
notifications: '通知',
|
||||
filament: 'フィラメント',
|
||||
network: 'ネットワーク',
|
||||
apiKeys: 'APIキー',
|
||||
virtualPrinter: '仮想プリンター',
|
||||
users: 'ユーザー',
|
||||
backup: 'バックアップ',
|
||||
globalEmail: 'グローバルメール',
|
||||
},
|
||||
// Email settings
|
||||
email: {
|
||||
smtpSettings: 'SMTP設定',
|
||||
smtpHost: 'SMTPサーバー',
|
||||
smtpPort: 'SMTPポート',
|
||||
security: 'セキュリティ',
|
||||
authentication: '認証',
|
||||
username: 'ユーザー名',
|
||||
password: 'パスワード',
|
||||
fromEmail: '送信元メールアドレス',
|
||||
fromName: '送信者名',
|
||||
testConnection: 'SMTP接続テスト',
|
||||
testRecipient: 'テスト受信者メール',
|
||||
sendTest: 'テストメール送信',
|
||||
sending: '送信中...',
|
||||
save: '設定を保存',
|
||||
saving: '保存中...',
|
||||
advancedAuth: '高度な認証',
|
||||
advancedAuthEnabled: '高度な認証が有効です',
|
||||
advancedAuthDisabled: '高度な認証が無効です',
|
||||
advancedAuthDisabledDesc: '高度な認証を有効にして、ユーザー管理のメールベース機能を有効化してください。',
|
||||
enable: '有効にする',
|
||||
disable: '無効にする',
|
||||
feature1: 'パスワードは自動生成され、新規ユーザーにメールで送信されます',
|
||||
feature2: 'ユーザーはユーザー名またはメールでログインできます',
|
||||
feature3: 'パスワード忘れ機能が利用可能です',
|
||||
feature4: '管理者はメールでユーザーパスワードをリセットできます',
|
||||
},
|
||||
|
||||
// General - Date/Time
|
||||
dateFormat: '日付形式',
|
||||
|
||||
@@ -29,7 +29,7 @@ import { useTheme, type ThemeStyle, type DarkBackground, type LightBackground, t
|
||||
import { useState, useEffect, useRef, useCallback } from 'react';
|
||||
import { Palette } from 'lucide-react';
|
||||
|
||||
const validTabs = ['general', 'network', 'plugs', 'notifications', 'filament', 'apikeys', 'virtual-printer', 'users', 'email', 'backup'] as const;
|
||||
const validTabs = ['general', 'network', 'plugs', 'email', 'notifications', 'filament', 'apikeys', 'virtual-printer', 'users', 'backup'] as const;
|
||||
type TabType = typeof validTabs[number];
|
||||
|
||||
export function SettingsPage() {
|
||||
@@ -945,6 +945,17 @@ export function SettingsPage() {
|
||||
</span>
|
||||
)}
|
||||
</button>
|
||||
<button
|
||||
onClick={() => handleTabChange('email')}
|
||||
className={`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${
|
||||
activeTab === 'email'
|
||||
? 'text-bambu-green border-bambu-green'
|
||||
: 'text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent'
|
||||
}`}
|
||||
>
|
||||
<Mail className="w-4 h-4" />
|
||||
{t('settings.tabs.globalEmail') || 'Global Email'}
|
||||
</button>
|
||||
<button
|
||||
onClick={() => handleTabChange('notifications')}
|
||||
className={`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${
|
||||
@@ -1026,17 +1037,6 @@ export function SettingsPage() {
|
||||
<span className="w-2 h-2 rounded-full bg-green-400" />
|
||||
)}
|
||||
</button>
|
||||
<button
|
||||
onClick={() => handleTabChange('email')}
|
||||
className={`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${
|
||||
activeTab === 'email'
|
||||
? 'text-bambu-green border-bambu-green'
|
||||
: 'text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent'
|
||||
}`}
|
||||
>
|
||||
<Mail className="w-4 h-4" />
|
||||
{t('settings.tabs.email') || 'Email'}
|
||||
</button>
|
||||
<button
|
||||
onClick={() => handleTabChange('backup')}
|
||||
className={`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${
|
||||
|
||||
File diff suppressed because one or more lines are too long
+1
-1
@@ -23,7 +23,7 @@
|
||||
|
||||
<!-- Splash screens for iOS -->
|
||||
<link rel="apple-touch-startup-image" href="/img/android-chrome-512x512.png" />
|
||||
<script type="module" crossorigin src="/assets/index-Ce6bi4R2.js"></script>
|
||||
<script type="module" crossorigin src="/assets/index-DywTesim.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-962x7uln.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
Reference in New Issue
Block a user