Update Saqel Platform: 2026-08-28 04:58:01
This commit is contained in:
@@ -11,57 +11,11 @@ use App\Core\Validator;
|
||||
class ChatController
|
||||
{
|
||||
/**
|
||||
* Auto-provisions the official teacher and sample students if database is empty
|
||||
* Zero Mock Policy - Only real database users are queried
|
||||
*/
|
||||
private static function ensureSeedUsers(): void
|
||||
{
|
||||
try {
|
||||
// Ensure default Teacher: الأستاذ حمزة الغويري
|
||||
$teacher = Database::selectOne("SELECT id FROM users WHERE role = 'teacher' LIMIT 1");
|
||||
if (!$teacher) {
|
||||
$uuid = sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x', mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0x0fff) | 0x4000, mt_rand(0, 0x3fff) | 0x8000, mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff));
|
||||
$phone = '962790000001';
|
||||
$phoneHash = Security::blindIndex($phone);
|
||||
$encPhone = Security::encrypt($phone);
|
||||
$encName = Security::encrypt('الأستاذ حمزة الغويري');
|
||||
$pwd = password_hash('Saqel@2026', PASSWORD_BCRYPT);
|
||||
$tId = Database::insert(
|
||||
"INSERT INTO users (uuid, full_name, phone_number, phone_hash, password_hash, role, status, token_version) VALUES (?, ?, ?, ?, ?, 'teacher', 'active', 1)",
|
||||
[$uuid, $encName, $encPhone, $phoneHash, $pwd]
|
||||
);
|
||||
Database::insert(
|
||||
"INSERT INTO teacher_profiles (user_id, specialization, revenue_share_pct, contract_type) VALUES (?, 'الرياضيات العلمي', 50.00, 'exclusive')",
|
||||
[$tId]
|
||||
);
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
error_log("Seed teacher note: " . $e->getMessage());
|
||||
}
|
||||
|
||||
try {
|
||||
// Ensure default sample students if no students exist
|
||||
$student = Database::selectOne("SELECT id FROM users WHERE role = 'student' LIMIT 1");
|
||||
if (!$student) {
|
||||
$sampleStudents = [
|
||||
['name' => 'أحمد محمد الغويري', 'phone' => '962790000002'],
|
||||
['name' => 'عمر بني صخر (علمي)', 'phone' => '962790000003'],
|
||||
['name' => 'سارة المشاقبة (توجيهي 2008)', 'phone' => '962790000004']
|
||||
];
|
||||
foreach ($sampleStudents as $s) {
|
||||
$uuid = sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x', mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0x0fff) | 0x4000, mt_rand(0, 0x3fff) | 0x8000, mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff));
|
||||
$phoneHash = Security::blindIndex($s['phone']);
|
||||
$encPhone = Security::encrypt($s['phone']);
|
||||
$encName = Security::encrypt($s['name']);
|
||||
$pwd = password_hash('Saqel@2026', PASSWORD_BCRYPT);
|
||||
Database::insert(
|
||||
"INSERT INTO users (uuid, full_name, phone_number, phone_hash, password_hash, role, status, token_version) VALUES (?, ?, ?, ?, ?, 'student', 'active', 1)",
|
||||
[$uuid, $encName, $encPhone, $phoneHash, $pwd]
|
||||
);
|
||||
}
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
error_log("Seed students note: " . $e->getMessage());
|
||||
}
|
||||
// No automatic demo users or students insertion
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user