Fix external user 'Access Forbidden' on agenda event card (#37362)
External users (fk_soc set) were blocked from opening agenda events
because GETPOSTINT('socid') returns 0 when no socid param is in the URL
(ActionComm::getNomUrl() only generates ?id=XXXXX).
The condition 0 != $user->socid then triggers accessforbidden() for
every external user.
Fix: fall back to $user->socid when socid is not in the URL, consistent
with the pattern used in all other card pages (contracts, invoices,
orders, etc.).
The existing restrictedArea() check still validates that the event's
fk_soc matches the user's company, so security is preserved.
Fixes #37361
Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
This commit is contained in:
parent
23f9aeded0
commit
2e02df9002
1 changed files with 3 additions and 0 deletions
|
|
@ -116,6 +116,9 @@ if (GETPOSTISSET("limityear") && GETPOSTINT("limityear") < 2100) {
|
|||
|
||||
// Security check
|
||||
$socid = GETPOSTINT('socid');
|
||||
if (empty($socid)) {
|
||||
$socid = $user->socid; // External users: fall back to their own company (consistent with other card pages)
|
||||
}
|
||||
$id = GETPOSTINT('id');
|
||||
if ($user->socid && ($socid != $user->socid)) {
|
||||
accessforbidden();
|
||||
|
|
|
|||
Loading…
Reference in a new issue