Jul 2nd - Optimized code 3
This commit is contained in:
+17
-11
@@ -1318,10 +1318,12 @@ def settings():
|
||||
'email_ingestion_move_to' : request.form.get('email_ingestion_move_to', 'Processed').strip(),
|
||||
'email_ingestion_interval': request.form.get('email_ingestion_interval', '5').strip(),
|
||||
}
|
||||
# Password: only update if a new value was provided
|
||||
# Password: only update if a new value was provided. Encrypted
|
||||
# at rest — see app/services/crypto_service.py.
|
||||
new_pw = request.form.get('email_ingestion_password', '').strip()
|
||||
if new_pw:
|
||||
fields['email_ingestion_password'] = new_pw
|
||||
from app.services.crypto_service import encrypt_secret
|
||||
fields['email_ingestion_password'] = encrypt_secret(new_pw)
|
||||
|
||||
changes = []
|
||||
for key, value in fields.items():
|
||||
@@ -1408,14 +1410,17 @@ def settings():
|
||||
registration_enabled = SystemSetting.get_bool('registration_enabled', default=True)
|
||||
survey_enabled = SystemSetting.get_bool('survey_enabled', default=True)
|
||||
email_settings = {
|
||||
'enabled' : SystemSetting.get_bool('email_ingestion_enabled', default=False),
|
||||
'host' : SystemSetting.get('email_ingestion_host', ''),
|
||||
'port' : SystemSetting.get('email_ingestion_port', '993'),
|
||||
'user' : SystemSetting.get('email_ingestion_user', ''),
|
||||
'password': SystemSetting.get('email_ingestion_password', ''),
|
||||
'folder' : SystemSetting.get('email_ingestion_folder', 'INBOX'),
|
||||
'move_to' : SystemSetting.get('email_ingestion_move_to', 'Processed'),
|
||||
'interval': SystemSetting.get('email_ingestion_interval', '5'),
|
||||
'enabled' : SystemSetting.get_bool('email_ingestion_enabled', default=False),
|
||||
'host' : SystemSetting.get('email_ingestion_host', ''),
|
||||
'port' : SystemSetting.get('email_ingestion_port', '993'),
|
||||
'user' : SystemSetting.get('email_ingestion_user', ''),
|
||||
# The stored password is never sent back to the browser — the field
|
||||
# is always rendered blank with a placeholder indicating whether one
|
||||
# is already configured (see settings.html).
|
||||
'has_password': bool(SystemSetting.get('email_ingestion_password', '')),
|
||||
'folder' : SystemSetting.get('email_ingestion_folder', 'INBOX'),
|
||||
'move_to' : SystemSetting.get('email_ingestion_move_to', 'Processed'),
|
||||
'interval' : SystemSetting.get('email_ingestion_interval', '5'),
|
||||
}
|
||||
branding_settings = {
|
||||
'app_name' : SystemSetting.get('app_name', 'TechDesk'),
|
||||
@@ -1477,7 +1482,8 @@ def email_ingestion_test():
|
||||
|
||||
# Fall back to the stored password if the admin left the field blank
|
||||
if not password:
|
||||
password = SystemSetting.get('email_ingestion_password', '')
|
||||
from app.services.crypto_service import decrypt_secret
|
||||
password = decrypt_secret(SystemSetting.get('email_ingestion_password', ''))
|
||||
|
||||
if not host or not user or not password:
|
||||
return jsonify(ok=False, message='Host, username, and password are required.')
|
||||
|
||||
Reference in New Issue
Block a user