Add exemption api to allow a Masquerade module exemption

Created on 19 December 2015, about 9 years ago
Updated 31 May 2024, 7 months ago

Problem/Motivation

I usually install the masquerade module on my sites to allow me to become other users when they need certain kinds of support.

Is there any way to bypass legal when I masquerading as a user? If the user I'm switching to is not up to date on their waiver, it forces me to agree to it on their behalf. Even worse, it loses knowledge that I'm a masqueraded user and I don't get the links to switch back to myself (usually in the navigation menu or a block)

Steps to reproduce

  1. Install the Masquerade module.
  2. Update the legal text.
  3. Masquerade as a user.
  4. Notice you're now logged out and masquerade is essentially broken.

Proposed resolution

Add an API to allow a module to declare a circumstance where a legal module requirement might be exempt.

Remaining tasks

Needs Review from Maintainer

User interface changes

None

API changes

Addedhook_is_legal_exempt to allow developers to determine if the exemption should happen.

Data model changes

None

Release notes snippet

Addedhook_is_legal_exempt to allow developers to determine if the exemption should happen.


/**
 * Tells the Legal Module to exempt a user from accepting the Legal forms.
 *
 * @param $is_exempt
 *  Set to TRUE if the user is exempt from the legal module requirements.
 */
function hook_is_legal_exempt(&$is_exempt) {
// Masquerading users are exempt from the legal module requirement.
  if (\Drupal::service('module_handler')->moduleExists('masquerade')) {
    if (\Drupal::service('masquerade')->isMasquerading()) {
      return TRUE;
    }
  }
}
πŸ› Bug report
Status

Fixed

Version

3.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States bkat

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

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024