Last access by a user should not change after masquerade as that user (D8)

Created on 22 March 2019, over 5 years ago
Updated 7 August 2024, about 2 months ago

Problem/Motivation

When someone masquerading as other user, the last user entity got changes in last access time (by core's user_last_access_subscriber service)
To prevent changing user entity it needs to decorate this service

Issue we have on D7 we also have on D8.
https://www.drupal.org/project/masquerade/issues/2921097 β†’

Proposed resolution

- introduce configuration to manage behavior - masquerade.settings configuration's key update_user_last_access to TRUE and post update hook for existing sites
- decorate user_last_access_subscriber service to prevent updates
- decorate session_manager.metadata_bag service to prevent "session is started" checks, see comments #23 and #24

Remaining tasks

- review and do testing with other contrib modules
- commit

User interface changes

no

API changes

- Added \Drupal\masquerade\Session\MetadataBag with setMasquerade, getMasquerade, cleanMasquerade methods accessible from session->getMetadata() object
- Added configuration with update hoot to preserve existing behavior

Data model changes

Session flag now wrapped into own session bag with useful methods

Release notes snippet

Masqueraded user's last access time no longer updated by default

πŸ› Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

πŸ‡­πŸ‡·Croatia xSDx

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

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