FluxFinance commited on
Commit
349c212
·
verified ·
1 Parent(s): ace4bb1

Upload Advisernote.py

Browse files
Files changed (1) hide show
  1. Advisernote.py +44 -2
Advisernote.py CHANGED
@@ -613,12 +613,54 @@ if check_password():
613
 
614
  st.markdown("**Mailbox Scan List**")
615
  current_mailboxes = load_active_mailboxes()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
616
  mailbox_rows = []
617
  for email_addr, entry in current_mailboxes.items():
618
  credential_part, separator, imap_host = entry.partition("||")
 
619
  mailbox_rows.append({
620
  "Mailbox": email_addr,
621
- "Authentication": "Individual password" if ":" in credential_part else "Common secret",
622
  "IMAP Host": imap_host.strip() if separator else "arrow.mxrouting.net",
623
  })
624
  st.dataframe(
@@ -627,7 +669,7 @@ if check_password():
627
  width="stretch",
628
  column_config={
629
  "Mailbox": st.column_config.TextColumn(width="medium"),
630
- "Authentication": st.column_config.TextColumn(width="medium"),
631
  "IMAP Host": st.column_config.TextColumn(width="large"),
632
  },
633
  )
 
613
 
614
  st.markdown("**Mailbox Scan List**")
615
  current_mailboxes = load_active_mailboxes()
616
+
617
+ st.markdown("**Update Mailbox Password**")
618
+ password_mailbox = st.selectbox(
619
+ "Mailbox",
620
+ list(current_mailboxes.keys()),
621
+ key="admin_password_mailbox",
622
+ )
623
+ new_mailbox_password = st.text_input(
624
+ "New individual password",
625
+ type="password",
626
+ key="admin_new_mailbox_password",
627
+ placeholder="Enter the new mailbox password",
628
+ )
629
+ password_col, common_col = st.columns(2)
630
+ if password_col.button("Update Password", width="stretch"):
631
+ if not new_mailbox_password:
632
+ st.error("Please enter the new mailbox password.")
633
+ else:
634
+ current_entry = current_mailboxes[password_mailbox]
635
+ _, separator, imap_host = current_entry.partition("||")
636
+ if not separator or not imap_host.strip():
637
+ st.error("The mailbox does not have a valid IMAP host.")
638
+ else:
639
+ updated_entry = f"{password_mailbox}:{new_mailbox_password}||{imap_host.strip()}"
640
+ if add_or_restore_mailbox(updated_entry):
641
+ st.session_state.pop("admin_new_mailbox_password", None)
642
+ st.success(f"Mailbox password updated: {password_mailbox}")
643
+ st.rerun()
644
+ else:
645
+ st.error("Failed to update the mailbox password.")
646
+
647
+ if common_col.button("Use Common Secret", width="stretch"):
648
+ current_entry = current_mailboxes[password_mailbox]
649
+ _, separator, imap_host = current_entry.partition("||")
650
+ if not separator or not imap_host.strip():
651
+ st.error("The mailbox does not have a valid IMAP host.")
652
+ elif add_or_restore_mailbox(f"{password_mailbox}||{imap_host.strip()}"):
653
+ st.session_state.pop("admin_new_mailbox_password", None)
654
+ st.success(f"Common secret enabled: {password_mailbox}")
655
+ st.rerun()
656
+
657
  mailbox_rows = []
658
  for email_addr, entry in current_mailboxes.items():
659
  credential_part, separator, imap_host = entry.partition("||")
660
+ _, password_separator, individual_password = credential_part.partition(":")
661
  mailbox_rows.append({
662
  "Mailbox": email_addr,
663
+ "Password": individual_password if password_separator else "Uses EMAIL_PASSWORD",
664
  "IMAP Host": imap_host.strip() if separator else "arrow.mxrouting.net",
665
  })
666
  st.dataframe(
 
669
  width="stretch",
670
  column_config={
671
  "Mailbox": st.column_config.TextColumn(width="medium"),
672
+ "Password": st.column_config.TextColumn(width="medium"),
673
  "IMAP Host": st.column_config.TextColumn(width="large"),
674
  },
675
  )