Update: 2026-05-03 23:57:27
This commit is contained in:
@@ -46,11 +46,22 @@ $encryptedName = Encryption::encrypt($data['name']);
|
||||
$encryptedEmail = Encryption::encrypt($data['email']);
|
||||
$emailHash = hash('sha256', strtolower($data['email'])); // For fast lookup during login
|
||||
|
||||
// 3. Determine Tenant ID
|
||||
$tenantId = null;
|
||||
if ($decoded['role'] === 'super_admin') {
|
||||
if (empty($data['tenant_id'])) {
|
||||
json_error('يجب اختيار المكتب المحاسبي', 422);
|
||||
}
|
||||
$tenantId = $data['tenant_id'];
|
||||
} else {
|
||||
$tenantId = $decoded['tenant_id'];
|
||||
}
|
||||
|
||||
// 4. Save to Database
|
||||
try {
|
||||
$stmt = $db->prepare("INSERT INTO users (tenant_id, name, email, email_hash, password_hash, role, created_at) VALUES (?, ?, ?, ?, ?, ?, ?)");
|
||||
$stmt->execute([
|
||||
$decoded['tenant_id'],
|
||||
$tenantId,
|
||||
$encryptedName,
|
||||
$encryptedEmail,
|
||||
$emailHash,
|
||||
|
||||
Reference in New Issue
Block a user