diff --git a/backend/app/Core/Response.php b/backend/app/Core/Response.php index 688d4a3..988dd48 100644 --- a/backend/app/Core/Response.php +++ b/backend/app/Core/Response.php @@ -39,9 +39,11 @@ class Response * @param int $code * @return void */ - public function json($data, int $code = 200): void + public function json($data, ?int $code = null): void { - $this->setStatusCode($code); + if ($code !== null) { + $this->setStatusCode($code); + } $this->setHeader('Content-Type', 'application/json; charset=utf-8'); // Setup CORS headers — restrict origin to the configured allowed domain diff --git a/backend/app/Views/TeacherPortal.php b/backend/app/Views/TeacherPortal.php index d37b356..a39caf4 100644 --- a/backend/app/Views/TeacherPortal.php +++ b/backend/app/Views/TeacherPortal.php @@ -660,10 +660,23 @@ class TeacherPortal } } + function getAuthToken() { + return localStorage.getItem('saqel_teacher_jwt') || getCookie('saqel_teacher_jwt') || ''; + } + + function getCookie(name) { + const v = document.cookie.match('(^|;) ?' + name + '=([^;]*)(;|$)'); + return v ? v[2] : null; + } + // 2. Load Conversations List via REST API async function loadConversations() { - const token = localStorage.getItem('saqel_teacher_jwt'); - if (!token) return; + const token = getAuthToken(); + const container = document.getElementById('conv_list_container'); + if (!token) { + if (container) container.innerHTML = '