IP Masking: Do not allow temporary users to thank other users

It has been decided to not allow temporary users to thank
other users (see task). This is because the transition
between anonymous and temporary account is nearly invisible,
and it might be confusing why the thanking ability appears
and hides.

Bug: T345679
Change-Id: I62e67327c9a80b3da9e98a2dccdd4ec2051f3026
This commit is contained in:
Martin Urbanec 2023-09-13 23:07:52 +02:00 committed by Jdlrobson
parent 42f2613d3d
commit 9cef38e80f
3 changed files with 9 additions and 8 deletions

View file

@ -32,7 +32,7 @@ abstract class ApiThank extends ApiBase {
}
protected function dieOnBadUser( User $user ) {
if ( $user->isAnon() ) {
if ( !$user->isNamed() ) {
$this->dieWithError( 'thanks-error-notloggedin', 'notloggedin' );
} elseif ( $user->pingLimiter( 'thanks-notification' ) ) {
$this->dieWithError( [ 'thanks-error-ratelimited', $user->getName() ], 'ratelimited' );

View file

@ -127,11 +127,12 @@ class Hooks implements
// Don't let users thank themselves.
// Exclude anonymous users.
// Exclude temp users (T345679)
// Exclude users who are blocked.
// Check whether bots are allowed to receive thanks.
// Don't allow thanking for a diff that includes multiple revisions
// Check whether we have a revision id to link to
if ( $userIdentity->isRegistered()
if ( $user->isNamed()
&& !$userIdentity->equals( $recipient )
&& !self::isUserBlockedFromTitle( $user, $revisionRecord->getPageAsLinkTarget() )
&& !self::isUserBlockedFromThanks( $user )

View file

@ -44,17 +44,17 @@ class ApiCoreThankUnitTest extends ApiTestCase {
* @covers \MediaWiki\Extension\Thanks\Api\ApiThank::dieOnUserBlockedFromThanks
*/
public function testDieOnBadUser(
$mockAnon,
$mockisNamed,
$mockPingLimited,
$mockBlock,
$dieMethod,
$expectedError
) {
$user = $this->createMock( User::class );
if ( $mockAnon !== null ) {
if ( $mockisNamed !== null ) {
$user->expects( $this->once() )
->method( 'isAnon' )
->willReturn( $mockAnon );
->method( 'isNamed' )
->willReturn( $mockisNamed );
}
if ( $mockPingLimited !== null ) {
$user->expects( $this->once() )
@ -83,14 +83,14 @@ class ApiCoreThankUnitTest extends ApiTestCase {
public static function provideDieOnBadUser() {
return [
'anon' => [
true,
false,
null,
null,
'dieOnBadUser',
'notloggedin'
],
'ping' => [
false,
true,
true,
null,
'dieOnBadUser',