Check if authentication has been set up.
(self)
| 261 | # ========================================================================= |
| 262 | |
| 263 | def is_configured(self) -> bool: |
| 264 | """Check if authentication has been set up.""" |
| 265 | try: |
| 266 | with self._get_auth_conn() as conn: |
| 267 | cursor = conn.cursor() |
| 268 | cursor.execute("SELECT COUNT(*) FROM auth") |
| 269 | return cursor.fetchone()[0] > 0 |
| 270 | except sqlite3.OperationalError as e: |
| 271 | if 'no such table' not in str(e).lower(): |
| 272 | logger.error(f"Error checking auth status: {e}") |
| 273 | return False |
| 274 | with self._lock: |
| 275 | try: |
| 276 | self._init_auth_db() |
| 277 | with self._get_auth_conn() as conn: |
| 278 | cursor = conn.cursor() |
| 279 | cursor.execute("SELECT COUNT(*) FROM auth") |
| 280 | return cursor.fetchone()[0] > 0 |
| 281 | except Exception as retry_err: |
| 282 | logger.debug(f"Auth DB initialized on demand; reporting unconfigured: {retry_err}") |
| 283 | return False |
| 284 | except Exception as e: |
| 285 | logger.error(f"Error checking auth status: {e}") |
| 286 | return False |
| 287 | |
| 288 | def get_auth_status(self, session=None) -> dict: |
| 289 | """Get current authentication status.""" |
no test coverage detected