Skip to content

Commit

Permalink
Fix: Match token login name by UID or e-mail address
Browse files Browse the repository at this point in the history
With this changes the login name gets matched against the token user's
e-mail address in addition to the login name.

This fixes the web login flow of the app, where the session is based on
the e-mail address but the token uses the UID.

Fixes #44164
  • Loading branch information
haffmans committed Jan 18, 2025
1 parent e0c1ea2 commit 9e8f6b2
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/private/User/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -780,12 +780,13 @@ private function validateToken($token, $user = null) {
* Check if login names match
*/
private function validateTokenLoginName(?string $loginName, IToken $token): bool {
if ($token->getLoginName() !== $loginName) {
// TODO: this makes it impossible to use different login names on browser and client
// e.g. login by e-mail '[email protected]' on browser for generating the token will not
// allow to use the client token with the login name 'user'.
$tokenUser = $this->manager->get($token->getUID());
$tokenEmail = $tokenUser->getEMailAddress();

if ($token->getLoginName() !== $loginName && $tokenEmail != $loginName) {
$this->logger->error('App token login name does not match', [
'tokenLoginName' => $token->getLoginName(),
'tokenEmailAddress' => $tokenEmail,
'sessionLoginName' => $loginName,
'app' => 'core',
'user' => $token->getUID(),
Expand Down

0 comments on commit 9e8f6b2

Please sign in to comment.