(REF) Invert relation between login functions. Prepare to reduce loads.
authorTim Otten <totten@civicrm.org>
Tue, 27 Jun 2023 21:36:23 +0000 (14:36 -0700)
committerTim Otten <totten@civicrm.org>
Fri, 30 Jun 2023 18:57:51 +0000 (11:57 -0700)
commit0f90ab0f12a174f4cf913f6292029f3266de8120
tree075634b760b5970b66eaa10b03ee96a14bf7d0d2
parentebad3d242b53dea4ae8bf85ef1574e5d871c142f
(REF) Invert relation between login functions. Prepare to reduce loads.

Before:

* Civi\Standalone\Security::loginAuthenticatedUserRecord() calls
  Civix\Authx\Standalone::loginStateless() and Civix\Authx\Standalone::loginStateful()
* The logged-in user may be loaded twice - e.g. for workflows that
  hit `loginAuthenticatedUserRecord()`

After

* Civix\Authx\Standalone::loginStateless() and Civix\Authx\Standalone::loginStateful()
  call Civi\Standalone\Security::loginAuthenticatedUserRecord()
* The logged-in user is still loaded twice... but it'll small fix to load only once.

Comments

* The redundancy arose because `loginAuthenticatedUserRecord()` had the full-record,
  and it called to `loginStateless()` (etc) with just ID or name - which then loaded
  the full-record again.
* One might ask: "Is one orientation conceptually or philosophically better
  than the other?" I don't have a good answer to that, but...  I think this
  patch makes for a nicer symmetry between `Civi\Authx\Standalone` and
  `Civi\Authx\{Drupal,WordPress,etc}`.  In all cases, they take the
  userID/username and then perform a 1-4 SLOC incantation that
  populates the global user-record.
ext/standaloneusers/Civi/Authx/Standalone.php
ext/standaloneusers/Civi/Standalone/Security.php