Cicalese has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/384625 )

Change subject: Added optional extra fields for authentication request.
......................................................................


Added optional extra fields for authentication request.

Change-Id: I15ecbc81304294548ae9cf1aed32a3dc44a38f03
---
M extension.json
M includes/PluggableAuthBeginAuthenticationRequest.php
M includes/PluggableAuthLogin.php
M includes/PluggableAuthPrimaryAuthenticationProvider.php
4 files changed, 23 insertions(+), 4 deletions(-)

Approvals:
  Cicalese: Verified; Looks good to me, approved
  jenkins-bot: Checked



diff --git a/extension.json b/extension.json
index c1fdc48..9b4954e 100644
--- a/extension.json
+++ b/extension.json
@@ -1,6 +1,6 @@
 {
        "name": "PluggableAuth",
-       "version": "5.2",
+       "version": "5.3",
        "author": [
                "[https://www.mediawiki.org/wiki/User:Cindy.cicalese Cindy 
Cicalese]"
        ],
@@ -49,7 +49,8 @@
        "config": {
                "PluggableAuth_EnableAutoLogin": false,
                "PluggableAuth_EnableLocalLogin": false,
-               "PluggableAuth_EnableLocalProperties": false
+               "PluggableAuth_EnableLocalProperties": false,
+               "PluggableAuth_ExtraLoginFields": []
        },
        "manifest_version": 1
 }
diff --git a/includes/PluggableAuthBeginAuthenticationRequest.php 
b/includes/PluggableAuthBeginAuthenticationRequest.php
index 9bcbe49..fb3f151 100644
--- a/includes/PluggableAuthBeginAuthenticationRequest.php
+++ b/includes/PluggableAuthBeginAuthenticationRequest.php
@@ -1,8 +1,10 @@
 <?php
 
 use \MediaWiki\Auth\ButtonAuthenticationRequest;
+use \MediaWiki\Auth\AuthManager;
 
-class PluggableAuthBeginAuthenticationRequest extends 
ButtonAuthenticationRequest {
+class PluggableAuthBeginAuthenticationRequest extends
+       ButtonAuthenticationRequest {
 
        public function __construct() {
                parent::__construct(
@@ -12,4 +14,11 @@
                        true);
        }
 
+       public function getFieldInfo() {
+               if ( $this->action !== AuthManager::ACTION_LOGIN ) {
+                       return [];
+               }
+               return array_merge( 
$GLOBALS['wgPluggableAuth_ExtraLoginFields'],
+                       parent::getFieldInfo() );
+       }
 }
diff --git a/includes/PluggableAuthLogin.php b/includes/PluggableAuthLogin.php
index 0eb4cca..113b226 100644
--- a/includes/PluggableAuthLogin.php
+++ b/includes/PluggableAuthLogin.php
@@ -7,6 +7,7 @@
        const RETURNTOURL_SESSION_KEY = 'PluggableAuthLoginReturnToUrl';
        const RETURNTOPAGE_SESSION_KEY = 'PluggableAuthLoginReturnToPage';
        const RETURNTOQUERY_SESSION_KEY = 'PluggableAuthLoginReturnToQuery';
+       const EXTRALOGINFIELDS_SESSION_KEY = 
'PluggableAuthLoginExtraLoginFields';
        const USERNAME_SESSION_KEY = 'PluggableAuthLoginUsername';
        const REALNAME_SESSION_KEY = 'PluggableAuthLoginRealname';
        const EMAIL_SESSION_KEY = 'PluggableAuthLoginEmail';
diff --git a/includes/PluggableAuthPrimaryAuthenticationProvider.php 
b/includes/PluggableAuthPrimaryAuthenticationProvider.php
index 4b62b5b..3f47ca0 100644
--- a/includes/PluggableAuthPrimaryAuthenticationProvider.php
+++ b/includes/PluggableAuthPrimaryAuthenticationProvider.php
@@ -15,9 +15,17 @@
                if ( !$request ) {
                        return AuthenticationResponse::newAbstain();
                }
+               $extraLoginFields = [];
+               foreach ( $GLOBALS['wgPluggableAuth_ExtraLoginFields'] as $key 
=> $value ) {
+                       if ( isset( $request, $key ) ) {
+                               $extraLoginFields[$key] = $request->$key;
+                       }
+               }
                $url = Title::newFromText( 'Special:PluggableAuthLogin' 
)->getFullURL();
                $this->manager->setAuthenticationSessionData(
                        PluggableAuthLogin::RETURNTOURL_SESSION_KEY, 
$request->returnToUrl );
+               $this->manager->setAuthenticationSessionData(
+                       PluggableAuthLogin::EXTRALOGINFIELDS_SESSION_KEY, 
$extraLoginFields );
                if ( isset( $_GET['returnto'] ) ) {
                        $returnto = $_GET['returnto'];
                } else {
@@ -124,7 +132,7 @@
                switch ( $action ) {
                        case AuthManager::ACTION_LOGIN:
                                return [
-                                        new 
PluggableAuthBeginAuthenticationRequest()
+                                       new 
PluggableAuthBeginAuthenticationRequest()
                                ];
                        default:
                                return [];

-- 
To view, visit https://gerrit.wikimedia.org/r/384625
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I15ecbc81304294548ae9cf1aed32a3dc44a38f03
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/PluggableAuth
Gerrit-Branch: master
Gerrit-Owner: Cicalese <[email protected]>
Gerrit-Reviewer: Cicalese <[email protected]>
Gerrit-Reviewer: MarkAHershberger <[email protected]>
Gerrit-Reviewer: Robert Vogel <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to