fix: Resolve getJSON method error in student national ID verification and enhance curriculum worker Gemini model handling

This commit is contained in:
Hamza-Ayed
2026-08-29 03:00:06 +03:00
parent 9a1cb3adfd
commit a8d0efbbea
4 changed files with 22 additions and 10 deletions
+10 -4
View File
@@ -462,7 +462,7 @@ class AuthController
*/
public function verifyNationalId(Request $request, Response $response): void
{
$body = $request->getJSON();
$body = $request->getBody();
$identityToken = $body['identity_token'] ?? '';
$nationalId = trim((string)($body['national_id'] ?? ''));
@@ -606,13 +606,19 @@ class AuthController
} else {
// Legacy / Fallback for already logged-in students updating profile
$studentId = (int)$request->user_id;
if (!$studentId) {
$authHeader = $request->getHeader('authorization', '');
if ($authHeader && preg_match('/Bearer\s(\S+)/i', $authHeader, $matches)) {
$payload = Security::verifyJWT($matches[1]);
if ($payload && isset($payload['user_id'])) {
$studentId = (int)$payload['user_id'];
}
}
}
if (!$studentId) {
$response->status(401)->json(['status' => 'error', 'message' => 'غير مصرح']);
return;
}
Database::query(
"UPDATE students SET full_name = ?, grade_level = ?, stream = ?, national_id = IF(? != '', ?, national_id), updated_at = NOW() WHERE id = ?",
[$fullName, $gradeLevel, $stream, $nationalId, $nationalId, $studentId]
);
$student = Database::selectOne("SELECT * FROM students WHERE id = ? LIMIT 1", [$studentId]);