Encrypt database and clear session data.
(self)
| 495 | self._db_ready = True # Mark ready anyway so the system isn't stuck |
| 496 | |
| 497 | def logout(self) -> dict: |
| 498 | """Encrypt database and clear session data.""" |
| 499 | try: |
| 500 | if self.is_configured() and self._fernet_key: |
| 501 | # Acquire the DB lock to prevent other threads from creating |
| 502 | # new DB connections during the encrypt window |
| 503 | from db_manager import _db_lock |
| 504 | with _db_lock: |
| 505 | # Close existing DB connections |
| 506 | self._close_db() |
| 507 | # Give a moment for connections to close |
| 508 | time.sleep(0.2) |
| 509 | # Encrypt the database |
| 510 | if os.path.exists(self.main_db_path): |
| 511 | self.encrypt_database() |
| 512 | self._fernet_key = None |
| 513 | |
| 514 | return {'success': True} |
| 515 | except Exception as e: |
| 516 | logger.error(f"Logout encryption failed: {e}") |
| 517 | return {'success': False, 'error': str(e)} |
| 518 | |
| 519 | # ========================================================================= |
| 520 | # PUBLIC API - PASSWORD CHANGE |
nothing calls this directly
no test coverage detected