Load user entity in Cookie AuthenticationProvider instead of using manual queries

Created on 26 September 2014, about 10 years ago
Updated 14 January 2024, 10 months ago

Problem/Motivation

The Cookie authentication provider currently executes SQL queries in order to construct an authenticated UserSession.

This is different from the BasicAuth authentication provider which simply loads the user from entity store.

It is quite common to actually have to load the user entity anyway, this could simplify some code (keep AccountInterface, but if authenticated user, then you can assume that you have a user entity).

Steps to reproduce

Proposed resolution

Simplify Cookie:authenticate() and load the user entity directly.

In order to prevent triggering the field translation subsystem prematurely, introduce ContentEntityBase::getFieldValue() which returns an untranslated value and use that for simple user entity properties (User::getLastAccessedTime(), User::isActive(), User::getTimezone(), User::getAccountName()).

Remaining tasks

  • Review
  • Commit

User interface changes

None.

API changes

API addition: ContentEntityBase::getFieldValue()

Data model changes

None.

Release notes snippet

📌 Task
Status

Needs work

Version

11.0 🔥

Component
User module 

Last updated about 12 hours ago

Created by

🇨🇭Switzerland berdir Switzerland

Live updates comments and jobs are added and updated live.
  • Needs reroll

    The patch will have to be re-rolled with new suggestions/changes described in the comments in the issue.

  • Performance

    It affects performance. It is often combined with the Needs profiling tag.

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