jenkins-bot has submitted this change and it was merged.

Change subject: Don't allow locked users to receive email
......................................................................


Don't allow locked users to receive email

Bug: T87559
Change-Id: I355d69496ca2871c1083094174a8291d303ff0a1
---
M includes/CentralAuthHooks.php
M tests/CentralAuthHooksUsingDatabaseTest.php
2 files changed, 15 insertions(+), 1 deletion(-)

Approvals:
  Hoo man: Looks good to me, approved
  Jforrester: Looks good to me, but someone else must approve
  jenkins-bot: Verified



diff --git a/includes/CentralAuthHooks.php b/includes/CentralAuthHooks.php
index 5119020..b4e49be 100644
--- a/includes/CentralAuthHooks.php
+++ b/includes/CentralAuthHooks.php
@@ -1140,7 +1140,12 @@
        static function onUserGetEmailAuthenticationTimestamp( $user, 
&$timestamp ) {
                $ca = CentralAuthUser::getInstance( $user );
                if ( $ca->isAttached() ) {
-                       $timestamp = $ca->getEmailAuthenticationTimestamp();
+                       if ( $ca->isLocked() ) {
+                               // Locked users shouldn't be receiving email 
(T87559)
+                               $timestamp = null;
+                       } else {
+                               $timestamp = 
$ca->getEmailAuthenticationTimestamp();
+                       }
                }
                return true;
        }
diff --git a/tests/CentralAuthHooksUsingDatabaseTest.php 
b/tests/CentralAuthHooksUsingDatabaseTest.php
index e8dd060..7874f24 100644
--- a/tests/CentralAuthHooksUsingDatabaseTest.php
+++ b/tests/CentralAuthHooksUsingDatabaseTest.php
@@ -26,6 +26,15 @@
        }
 
        /**
+        * @covers CentralAuthHooks::onUserGetEmailAuthenticationTimestampp
+        */
+       public function testLockedEmailDisabled() {
+               $user = User::newFromName( 'GlobalLockedUser' );
+               $this->assertFalse( $user->isEmailConfirmed() );
+               $this->assertFalse( $user->canReceiveEmail() );
+       }
+
+       /**
         * @dataProvider provideAbortLogin
         * @covers CentralAuthHooks::onAbortLogin
         */

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I355d69496ca2871c1083094174a8291d303ff0a1
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/CentralAuth
Gerrit-Branch: master
Gerrit-Owner: Legoktm <[email protected]>
Gerrit-Reviewer: CSteipp <[email protected]>
Gerrit-Reviewer: Hoo man <[email protected]>
Gerrit-Reviewer: Jalexander <[email protected]>
Gerrit-Reviewer: Jforrester <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to