From 75c447fe030aaf9fc03a17fd7a9078ed48048127 Mon Sep 17 00:00:00 2001 From: Iyeoluwa Akinrinola Date: Fri, 25 Jul 2025 11:58:57 +0100 Subject: [PATCH] Remove hardcoded Zoho credentials - now users input credentials through frontend --- app.py | 6 ++++++ email_processor.py | 20 ++++++++++++++++---- templates/settings.html | 14 ++++++++++++++ zoho_client.py | 12 ++++++++---- 4 files changed, 44 insertions(+), 8 deletions(-) diff --git a/app.py b/app.py index a5594a7..2b8ec3e 100644 --- a/app.py +++ b/app.py @@ -25,6 +25,8 @@ def load_config(): # Default configuration default_config = { 'email_address': 'projects@manaknightdigital.com', + 'zoho_email': '', # Will be set by user through frontend + 'zoho_app_password': '', # Will be set by user through frontend 'time_frames': [ {'name': '1-24 hours', 'hours': 24, 'alert_level': 1}, {'name': '24-48 hours', 'hours': 48, 'alert_level': 2}, @@ -93,6 +95,10 @@ def update_settings(): # Update email address config['email_address'] = request.form.get('email_address', config['email_address']) + # Update Zoho credentials + config['zoho_email'] = request.form.get('zoho_email', config.get('zoho_email', '')) + config['zoho_app_password'] = request.form.get('zoho_app_password', config.get('zoho_app_password', '')) + # Update email days back config['email_days_back'] = int(request.form.get('email_days_back', 7)) diff --git a/email_processor.py b/email_processor.py index 8e6a8ae..78c1dab 100644 --- a/email_processor.py +++ b/email_processor.py @@ -12,13 +12,25 @@ from dotenv import load_dotenv load_dotenv() class EmailProcessor: - def __init__(self, agency_domains: List[str] = None): - self.zoho_client = ZohoClient() - self.triage = EmailTriage() + def __init__(self, agency_domains=None): + """Initialize the email processor""" + self.agency_domains = agency_domains or ['projects@manaknightdigital.com'] + + # Load config to get Zoho credentials + from app import load_config + config = load_config() + + # Initialize Zoho client with credentials from config + self.zoho_client = ZohoClient( + email=config.get('zoho_email'), + app_password=config.get('zoho_app_password') + ) + + # Initialize thread tracker self.tracker = ThreadTracker() + self.triage = EmailTriage() self.ai_analyzer = AIAnalyzer() self.whatsapp_sender = WhatsAppSender() - self.agency_domains = agency_domains or ['projects@manaknightdigital.com'] def process_emails(self, max_results: int = 100, send_alerts: bool = True, days_back: int = 7, time_frames: List[Dict] = None) -> Dict[str, Any]: """Main processing pipeline with optional WhatsApp alerts""" diff --git a/templates/settings.html b/templates/settings.html index ccc3e10..63acf03 100644 --- a/templates/settings.html +++ b/templates/settings.html @@ -30,6 +30,20 @@
The email address that will be checked for new messages.
+
+ + +
Your Zoho email address for IMAP access.
+
+ +
+ + +
App password for Zoho IMAP access (not your regular password).
+
+