Added UI and functionality for profiles

This commit is contained in:
2026-02-12 14:17:24 -08:00
parent f879d25bc7
commit 8fc8d737e5
7 changed files with 282 additions and 139 deletions

View File

@@ -33,10 +33,24 @@ if ($role_id <= 0) {
}
try {
$pdo->beginTransaction();
// Create user
$stmt = $pdo->prepare("INSERT INTO users (email, password_hash, role_id) VALUES (?, ?, ?)");
$stmt->execute([$email, $hash, $role_id]);
$userId = (int)$pdo->lastInsertId();
// Create default profile for this user
$stmt = $pdo->prepare("INSERT INTO profiles (user_id, name, is_default) VALUES (?, 'Default', 1)");
$stmt->execute([$userId]);
$pdo->commit();
echo json_encode(['success' => true]);
} catch (Throwable $e) {
if ($pdo->inTransaction()) $pdo->rollBack();
http_response_code(409);
echo json_encode(['success' => false, 'error' => 'Account already exists']);
}