[FEAT] Ruolo Consulente + Wizard Registrazione v2
- register.html: step 0 scelta profilo (Azienda / Consulente) - onboarding.html: wizard 4-step con P.IVA obbligatoria (auto-fetch CertiSource) - companies.html: nuova dashboard consulente con cards aziende e compliance score - common.js: org-switcher sidebar + role labels corretti per consulente - login.html: routing post-login (consulente → companies.html) - api.js: isConsultant(), setUserRole(), register con user_type - AuthController: user_type=consultant → role=consultant in users table - OnboardingController: multi-org per consulente, duplicate VAT check - 005_consultant_support.sql: aggiunge 'consultant' a user_organizations.role ENUM Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
ba21534e6a
commit
7080695d06
@@ -26,6 +26,8 @@ class AuthController extends BaseController
|
||||
$password = $this->getParam('password');
|
||||
$fullName = trim($this->getParam('full_name'));
|
||||
$phone = $this->getParam('phone');
|
||||
$userType = $this->getParam('user_type', 'azienda'); // 'azienda' | 'consultant'
|
||||
$role = ($userType === 'consultant') ? 'consultant' : 'employee';
|
||||
|
||||
// Validazione email
|
||||
if (!$this->validateEmail($email)) {
|
||||
@@ -54,7 +56,7 @@ class AuthController extends BaseController
|
||||
'password_hash' => password_hash($password, PASSWORD_DEFAULT),
|
||||
'full_name' => $fullName,
|
||||
'phone' => $phone,
|
||||
'role' => 'employee',
|
||||
'role' => $role,
|
||||
'is_active' => 1,
|
||||
]);
|
||||
|
||||
@@ -64,14 +66,14 @@ class AuthController extends BaseController
|
||||
|
||||
// Audit log
|
||||
$this->currentUser = ['id' => $userId];
|
||||
$this->logAudit('user_registered', 'user', $userId);
|
||||
$this->logAudit('user_registered', 'user', $userId, ['user_type' => $userType]);
|
||||
|
||||
$this->jsonSuccess([
|
||||
'user' => [
|
||||
'id' => $userId,
|
||||
'email' => $email,
|
||||
'full_name' => $fullName,
|
||||
'role' => 'employee',
|
||||
'role' => $role,
|
||||
],
|
||||
'access_token' => $accessToken,
|
||||
'refresh_token' => $refreshToken,
|
||||
|
||||
Reference in New Issue
Block a user