Merge pull request #77 from christianlouis/copilot/fix-unauthorized-error
Fix 401 Unauthorized on poll-status dashboard widget
This commit is contained in:
+4
-7
@@ -581,16 +581,13 @@ async def trigger_imap_poll(auth: dict = Depends(require_admin_auth)):
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# API endpoint to check status of IMAP polling
|
# API endpoint to check status of IMAP polling (public, read-only)
|
||||||
@app.get("/api/v1/admin/poll-status")
|
@app.get("/api/v1/poll-status")
|
||||||
async def get_poll_status(auth: dict = Depends(require_admin_auth)):
|
async def get_poll_status():
|
||||||
"""
|
"""
|
||||||
Get the status of IMAP polling (admin only - requires authentication)
|
Get the status of IMAP polling (read-only, no authentication required).
|
||||||
|
|
||||||
Security: Requires either X-API-Key header or Bearer token
|
|
||||||
"""
|
"""
|
||||||
return {
|
return {
|
||||||
"is_running": background_task is not None and not background_task.done(),
|
"is_running": background_task is not None and not background_task.done(),
|
||||||
"last_check": last_check_time.isoformat() if last_check_time else None,
|
"last_check": last_check_time.isoformat() if last_check_time else None,
|
||||||
"authenticated_by": auth.get("auth_type"),
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -199,7 +199,11 @@ function dashboardApp() {
|
|||||||
|
|
||||||
async getImapStatus() {
|
async getImapStatus() {
|
||||||
try {
|
try {
|
||||||
const response = await fetch('/api/v1/admin/poll-status');
|
const response = await fetch('/api/v1/poll-status');
|
||||||
|
if (!response.ok) {
|
||||||
|
console.error('Error checking IMAP status:', response.status);
|
||||||
|
return;
|
||||||
|
}
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
|
|
||||||
const statusIcon = document.getElementById('imap-status-icon');
|
const statusIcon = document.getElementById('imap-status-icon');
|
||||||
|
|||||||
Reference in New Issue
Block a user