summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'PluggableAuth/includes/PluggableAuthLogin.php')
-rw-r--r--PluggableAuth/includes/PluggableAuthLogin.php23
1 files changed, 16 insertions, 7 deletions
diff --git a/PluggableAuth/includes/PluggableAuthLogin.php b/PluggableAuth/includes/PluggableAuthLogin.php
index c27e6a6b..21ec13c8 100644
--- a/PluggableAuth/includes/PluggableAuthLogin.php
+++ b/PluggableAuth/includes/PluggableAuthLogin.php
@@ -1,6 +1,7 @@
<?php
-use \MediaWiki\Auth\AuthManager;
+use MediaWiki\Auth\AuthManager;
+use MediaWiki\MediaWikiServices;
class PluggableAuthLogin extends UnlistedSpecialPage {
@@ -22,14 +23,19 @@ class PluggableAuthLogin extends UnlistedSpecialPage {
*/
public function execute( $param ) {
wfDebugLog( 'PluggableAuth', 'In execute()' );
- $authManager = AuthManager::singleton();
+ if ( method_exists( MediaWikiServices::class, 'getAuthManager' ) ) {
+ // MediaWiki 1.35+
+ $authManager = MediaWikiServices::getInstance()->getAuthManager();
+ } else {
+ $authManager = AuthManager::singleton();
+ }
$user = $this->getUser();
$pluggableauth = PluggableAuth::singleton();
$error = null;
if ( $pluggableauth ) {
if ( $pluggableauth->authenticate( $id, $username, $realname, $email,
- $error ) ) {
- if ( is_null( $id ) ) {
+ $error ) ) {
+ if ( $id === null ) {
$user->loadDefaults( $username );
$user->mName = $username;
$user->mRealName = $realname;
@@ -41,6 +47,7 @@ class PluggableAuthLogin extends UnlistedSpecialPage {
$user->mId = $id;
$user->loadFromId();
wfDebugLog( 'PluggableAuth', 'Authenticated existing user: ' . $user->mName );
+ Hooks::run( 'PluggableAuthPopulateGroups', [ $user ] );
}
$authorized = true;
Hooks::run( 'PluggableAuthUserAuthorization', [ $user, &$authorized ] );
@@ -58,7 +65,7 @@ class PluggableAuthLogin extends UnlistedSpecialPage {
}
} else {
wfDebugLog( 'PluggableAuth', 'Authentication failure.' );
- if ( is_null( $error ) ) {
+ if ( $error === null ) {
$error = wfMessage( 'pluggableauth-authentication-failure' )->text();
} else {
if ( !is_string( $error ) ) {
@@ -68,14 +75,16 @@ class PluggableAuthLogin extends UnlistedSpecialPage {
}
}
}
- if ( !is_null( $error ) ) {
+ if ( $error !== null ) {
$authManager->setAuthenticationSessionData( self::ERROR_SESSION_KEY,
$error );
}
$returnToUrl = $authManager->getAuthenticationSessionData(
self::RETURNTOURL_SESSION_KEY );
- if ( is_null( $returnToUrl ) || count( $returnToUrl ) === 0 ) {
+ if ( $returnToUrl === null || strlen( $returnToUrl ) === 0 ) {
wfDebugLog( 'PluggableAuth', 'ERROR: return to URL is null or empty' );
+ $this->getOutput()->wrapWikiMsg( "<div class='error'>\n$1\n</div>",
+ 'pluggableauth-fatal-error' );
} else {
$this->getOutput()->redirect( $returnToUrl );
}