nixos/hosts/vm/mediakiwi/WSOAuth.patch

50 lines
2.3 KiB
Diff

diff --git a/sql/postgres/table_wsoauth_multiauth_mappings.sql b/sql/postgres/table_wsoauth_multiauth_mappings.sql
index d2917db..b903ba7 100644
--- a/sql/postgres/table_wsoauth_multiauth_mappings.sql
+++ b/sql/postgres/table_wsoauth_multiauth_mappings.sql
@@ -1,5 +1,5 @@
CREATE TABLE /*_*/wsoauth_multiauth_mappings (
- wsoauth_user int unsigned NOT NULL,
+ wsoauth_user int NOT NULL,
wsoauth_remote_name varchar(512) NOT NULL,
wsoauth_provider_id varchar(255) NOT NULL,
PRIMARY KEY (wsoauth_remote_name, wsoauth_provider_id)
diff --git a/src/WSOAuth.php b/src/WSOAuth.php
index 3a94c87..e077b9e 100644
--- a/src/WSOAuth.php
+++ b/src/WSOAuth.php
@@ -308,11 +308,12 @@ class WSOAuth extends PluggableAuth {
// Set $realname and $email to the values returned from the authentication provider, if they are available
$realname = $remoteUserInfo['realname'] ?? null;
$email = $remoteUserInfo['email'] ?? null;
+ $username = ucfirst( $remoteUserInfo['name'] );
- $remoteUsername = ucfirst( $remoteUserInfo['name'] );
- $localUserId = $this->getLocalAccountID( $remoteUsername );
+ $remoteUserId = $remoteUserInfo['remoteUserId'] ?? $username;
+ $localUserId = $this->getLocalAccountID( $remoteUserId );
- $this->session->set( self::WSOAUTH_REMOTE_USERNAME_SESSION_KEY, $remoteUsername );
+ $this->session->set( self::WSOAUTH_REMOTE_USERNAME_SESSION_KEY, $remoteUserId );
$this->session->save();
if ( $localUserId !== 0 ) {
@@ -326,7 +327,7 @@ class WSOAuth extends PluggableAuth {
$currentUser = RequestContext::getMain()->getUser();
$currentUserId = $currentUser->getId();
- $this->createMapping( $currentUserId, $remoteUsername );
+ $this->createMapping( $currentUserId, $remoteUserId );
// Log the account in like normal
$username = $currentUser->getName();
@@ -339,7 +340,7 @@ class WSOAuth extends PluggableAuth {
throw new ContinuationException( wfMessage( "wsoauth-remote-only-accounts-disabled" )->parse() );
}
- $desiredLocalUsername = $this->useRealNameAsUsername && $realname !== null ? $realname : $remoteUsername;
+ $desiredLocalUsername = $this->useRealNameAsUsername && $realname !== null ? $realname : $username;
$userId = User::newFromName( $desiredLocalUsername )->idForName();
if ( $userId > 0 && $this->migrateUsersByUsername ) {