Add a hook to allow other modules to grant masquerading

Created on 26 June 2024, 10 months ago

Problem/Motivation

With more sophisticated logic it's possible the standard logic is not enough and some custom logic to decide whether a user can masquerade as another user is needed.

Proposed resolution

The attached patch adds a new hook to add this feature.
It also tried to streamline the logic of the module, with a single new function which performs the check.

Remaining tasks

Testing.

User interface changes

None.

API changes

A new hook has been added.
In the refactoring the permissions I tried to apply the existing permissions in a strict way:
- a user needs at least "masquerade as user" to perform any logic
- a user with "masquerade as any user" can masquerade as any user, standard or admin depending on the "masquerade as admin" permission

It is possible that some site has a different interpretation of these permissions and that this breaks their logic; if it does, it should at worst revoke some permissions, rather than grant them.

Data model changes

None.

Feature request
Status

Active

Version

1.0

Component

Code

Created by

🇮🇹Italy marco

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @marco
  • 🇮🇹Italy marco

    New patch, which fixes a warning.

    interdiff:
    63c63
    < + $can_masquerade_as_user = masquerade_can_masquerade($account);
    ---
    > + $can_masquerade_as_user = masquerade_can_masquerade(user_load($account));

Production build 0.71.5 2024