fix: Resolve getJSON method error in student national ID verification and enhance curriculum worker Gemini model handling
This commit is contained in:
@@ -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]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user