Cicalese has submitted this change and it was merged.

Change subject: moved addition of user to database until after authorization 
decision, fixed debug formatting
......................................................................


moved addition of user to database until after authorization decision, fixed 
debug formatting

Change-Id: Ie3371104a3348b9aa5364424c79b14ce67979e15
---
M PluggableAuth.class.php
M PluggableAuth.php
2 files changed, 20 insertions(+), 14 deletions(-)

Approvals:
  Cicalese: Verified; Looks good to me, approved



diff --git a/PluggableAuth.class.php b/PluggableAuth.class.php
index 62f3444..cdeef58 100644
--- a/PluggableAuth.class.php
+++ b/PluggableAuth.class.php
@@ -1,7 +1,7 @@
 <?php
 
 /*
- * Copyright (c) 2014 The MITRE Corporation
+ * Copyright (c) 2015 The MITRE Corporation
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -67,7 +67,7 @@
                                        session_unset();
                                        session_destroy();
                                }
-                               wfDebug( "Session timed out." );
+                               wfDebug( "Session timed out." . PHP_EOL );
                        }
                        $_SESSION['LAST_ACTIVITY'] = $time;
 
@@ -77,7 +77,7 @@
                                        $GLOBALS['PluggableAuth_Timeout'] ) {
                                session_regenerate_id( true );
                                $_SESSION['CREATED'] = $time;
-                               wfDebug( "Session regenerated." );
+                               wfDebug( "Session regenerated." . PHP_EOL );
                        }
 
                }
@@ -213,18 +213,16 @@
                                        $user->mEmail = $email;
                                        $user->mEmailAuthenticated = 
wfTimestamp();
                                        $user->mTouched = wfTimestamp();
-                                       $user->addToDatabase();
-                                       $instance->saveExtraAttributes( $id );
-                                       wfDebug( "Authenticated/created new 
user: " . $username );
+                                       $new_user = true;
+                                       wfDebug( "Authenticated new user: " . 
$username . PHP_EOL );
                                } else {
                                        $user->mId = $id;
-                                       $user->loadFromDatabase();
-                                       self::updateUser( $user, $realname, 
$email );
-                                       $user->saveToCache();
-                                       wfDebug( "Authenticated existing user: 
" . $user->mName );
+                                       $user->loadFromId();
+                                       $new_user = false;
+                                       wfDebug( "Authenticated existing user: 
" . $user->mName . PHP_EOL );
                                }
                        } else {
-                               wfDebug( "Authentication failure." );
+                               wfDebug( "Authentication failure." . PHP_EOL );
                                return false;
                        }
                } else {
@@ -237,6 +235,14 @@
                $returnto = null;
                $params = null;
                if ( $authorized ) {
+                       if ( $new_user ) {
+                               $user->addToDatabase();
+                               $instance->saveExtraAttributes( $id );
+                               wfDebug( "Added new user: " . $username . 
PHP_EOL );
+                       } else {
+                               self::updateUser( $user, $realname, $email );
+                               wfDebug( "Updated existing user: " . 
$user->mName . PHP_EOL );
+                       }
                        if ( session_id() == '' ) {
                                wfSetupSession();
                        }
@@ -316,7 +322,7 @@
                                'PluggableAuth' ) ) {
                        return new $GLOBALS['PluggableAuth_Class'];
                }
-               wfDebug( "Could not get authentication plugin instance." );
+               wfDebug( "Could not get authentication plugin instance." . 
PHP_EOL );
                return false;
 
        }
diff --git a/PluggableAuth.php b/PluggableAuth.php
index 869e76b..e4ab786 100644
--- a/PluggableAuth.php
+++ b/PluggableAuth.php
@@ -1,7 +1,7 @@
 <?php
 
 /*
- * Copyright (c) 2014 The MITRE Corporation
+ * Copyright (c) 2015 The MITRE Corporation
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -29,7 +29,7 @@
 $GLOBALS['wgExtensionCredits']['other'][] = array (
        'path' => __FILE__,
        'name' => 'PluggableAuth',
-       'version' => '1.1',
+       'version' => '1.2',
        'author' => array(
                '[https://www.mediawiki.org/wiki/User:Cindy.cicalese Cindy 
Cicalese]'
        ),

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ie3371104a3348b9aa5364424c79b14ce67979e15
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/PluggableAuth
Gerrit-Branch: master
Gerrit-Owner: Cicalese <cical...@mitre.org>
Gerrit-Reviewer: Cicalese <cical...@mitre.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to