fix: Resolve OTP verification instant transition and ensure bulletproof non-crashing conversation contact listing
This commit is contained in:
@@ -34,7 +34,11 @@ class ChatController
|
|||||||
[$tId]
|
[$tId]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
error_log("Seed teacher note: " . $e->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
// Ensure default sample students if no students exist
|
// Ensure default sample students if no students exist
|
||||||
$student = Database::selectOne("SELECT id FROM users WHERE role = 'student' LIMIT 1");
|
$student = Database::selectOne("SELECT id FROM users WHERE role = 'student' LIMIT 1");
|
||||||
if (!$student) {
|
if (!$student) {
|
||||||
@@ -55,8 +59,8 @@ class ChatController
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (\Exception $e) {
|
} catch (\Throwable $e) {
|
||||||
error_log("Seed users note: " . $e->getMessage());
|
error_log("Seed students note: " . $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -81,7 +85,7 @@ class ChatController
|
|||||||
ORDER BY u.id DESC
|
ORDER BY u.id DESC
|
||||||
LIMIT 100
|
LIMIT 100
|
||||||
", [$userId]);
|
", [$userId]);
|
||||||
} catch (\Exception $e) {
|
} catch (\Throwable $e) {
|
||||||
error_log("Users select in getConversations error: " . $e->getMessage());
|
error_log("Users select in getConversations error: " . $e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,12 +111,20 @@ class ChatController
|
|||||||
WHERE sender_id = ? AND receiver_id = ? AND is_read = 0
|
WHERE sender_id = ? AND receiver_id = ? AND is_read = 0
|
||||||
", [$otherId, $userId]);
|
", [$otherId, $userId]);
|
||||||
$unreadCount = (int)($unreadRow['cnt'] ?? 0);
|
$unreadCount = (int)($unreadRow['cnt'] ?? 0);
|
||||||
} catch (\Exception $e) {
|
} catch (\Throwable $e) {
|
||||||
// Ignore per-user message query issue if any
|
// Ignore per-user message query issue if any
|
||||||
}
|
}
|
||||||
|
|
||||||
$rawName = (string)($row['encrypted_name'] ?? '');
|
$rawName = (string)($row['encrypted_name'] ?? '');
|
||||||
$decryptedName = Security::decrypt($rawName) ?: $rawName;
|
$decryptedName = $rawName;
|
||||||
|
try {
|
||||||
|
$dec = Security::decrypt($rawName);
|
||||||
|
if (!empty($dec)) {
|
||||||
|
$decryptedName = $dec;
|
||||||
|
}
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
$decryptedName = $rawName;
|
||||||
|
}
|
||||||
|
|
||||||
$conversations[] = [
|
$conversations[] = [
|
||||||
'user_id' => $otherId,
|
'user_id' => $otherId,
|
||||||
|
|||||||
@@ -1300,6 +1300,7 @@ class StudentPortal
|
|||||||
}
|
}
|
||||||
document.cookie = "saqel_student_jwt=" + token + "; path=/; max-age=2592000; SameSite=Lax";
|
document.cookie = "saqel_student_jwt=" + token + "; path=/; max-age=2592000; SameSite=Lax";
|
||||||
initWebSocket(token);
|
initWebSocket(token);
|
||||||
|
renderDashboard(user);
|
||||||
await checkStudentSession(token);
|
await checkStudentSession(token);
|
||||||
} else {
|
} else {
|
||||||
showError(data.message || 'رمز التحقق غير صحيح');
|
showError(data.message || 'رمز التحقق غير صحيح');
|
||||||
|
|||||||
@@ -957,12 +957,14 @@ class TeacherPortal
|
|||||||
if (res.ok && data.status === 'success' && data.data?.token) {
|
if (res.ok && data.status === 'success' && data.data?.token) {
|
||||||
const token = data.data.token;
|
const token = data.data.token;
|
||||||
const user = data.data.user;
|
const user = data.data.user;
|
||||||
|
const profile = data.data.profile || {};
|
||||||
localStorage.setItem('saqel_teacher_jwt', token);
|
localStorage.setItem('saqel_teacher_jwt', token);
|
||||||
if (user) {
|
if (user) {
|
||||||
localStorage.setItem('saqel_teacher_user', JSON.stringify(user));
|
localStorage.setItem('saqel_teacher_user', JSON.stringify({ ...user, ...profile }));
|
||||||
}
|
}
|
||||||
document.cookie = "saqel_teacher_jwt=" + token + "; path=/; max-age=2592000; SameSite=Lax";
|
document.cookie = "saqel_teacher_jwt=" + token + "; path=/; max-age=2592000; SameSite=Lax";
|
||||||
initWebSocket(token);
|
initWebSocket(token);
|
||||||
|
renderDashboard(user, profile);
|
||||||
await checkTeacherSession(token);
|
await checkTeacherSession(token);
|
||||||
} else {
|
} else {
|
||||||
showError(data.message || 'رمز التحقق غير صحيح');
|
showError(data.message || 'رمز التحقق غير صحيح');
|
||||||
|
|||||||
Reference in New Issue
Block a user