1) user invitation 2) app access control 3) txn quota guard
This commit is contained in:
@@ -191,11 +191,17 @@ try {
|
||||
// ── Step 11: Map user as company owner ───────────────────────────────────
|
||||
// company_map_user is the many-to-many table between users and companies.
|
||||
// 'owner' role grants full admin access within the company.
|
||||
// app_access mirrors the owner's license (user.app_access) so the column
|
||||
// is never NULL and switch_branch reads consistent data.
|
||||
$sth = $pdo1->prepare("SELECT app_access FROM user WHERE user_id = :u LIMIT 1");
|
||||
$sth->execute([':u' => $user_id]);
|
||||
$owner_app_access = $sth->fetchColumn() ?: 'wms';
|
||||
|
||||
$sth = $pdo1->prepare("
|
||||
INSERT INTO company_map_user (company_id, user_id, role, created_at)
|
||||
VALUES (:company_id, :user_id, 'owner', NOW())
|
||||
INSERT INTO company_map_user (company_id, user_id, role, app_access, created_at)
|
||||
VALUES (:company_id, :user_id, 'owner', :app_access, NOW())
|
||||
");
|
||||
$sth->execute([':company_id' => $company_id, ':user_id' => $user_id]);
|
||||
$sth->execute([':company_id' => $company_id, ':user_id' => $user_id, ':app_access' => $owner_app_access]);
|
||||
db_check($sth, $answer);
|
||||
|
||||
// ── Step 12: Activate user account and set default company ───────────────
|
||||
|
||||
Reference in New Issue
Block a user