Page MenuHomePhabricator

Create a function that checks if a username is a temporary user in JS
Closed, ResolvedPublic

Description

Following on T327317, which introduces a way to check if a global session user is a temporary, there is still a need to create a function in Javascript that checks if a given username is a temporary user.

AC

  • Create a function that checks if a username given is a temporary username
  • write tests for the fucntion.

Testing notes

  • This can be tested on Beta, local, etc
  • On a page where this code is loaded (e.g. Special:Block), this function can be tested in the browser developer tools console by calling: mw.util.isTemporaryUser( /* Some user name */ )
  • It should return true for a temporary user name and false otherwise

Event Timeline

Change 883691 had a related patch set uploaded (by TsepoThoabala; author: TsepoThoabala):

[mediawiki/core@master] Create a function that checks if a username is a temporary user in JS

https://gerrit.wikimedia.org/r/883691

Change 883691 merged by jenkins-bot:

[mediawiki/core@master] Create a function that checks if a username is a temporary user in JS

https://gerrit.wikimedia.org/r/883691

dom_walden subscribed.

When IP Masking is enabled, the function mw.util.isTemporaryUser() returns true for all usernames which start with an asterisk. I tested with the first 500 users on beta dewiki and the first 5000 users on mediawiki.org.

I also called it with every character in the unicode set. It only recognised one as valid: *.

I repeated the above with IP Masking disabled (on enwiki beta) and it always returned false.

I briefly tested changing the value of $wgAutoCreateTempUser['matchPattern'] to see that it would match whatever pattern was set there.

There are currently a lot of usernames on production which start with asterisks, which this function will recognise as temporary accounts. I am assuming that in the future named accounts matching $wgAutoCreateTempUser['matchPattern'] will not be allowed and will be reserved for temporary accounts, such that the output of mw.util.isTemporaryUser() will always be consistent with our username policies.

Test enviroment: https://de.wikipedia.beta.wmflabs.org MediaWiki 1.40.0-alpha (0bd139f) 08:03, 23 February 2023.

There are currently a lot of usernames on production which start with asterisks, which this function will recognise as temporary accounts. [...]

This will be solved via T307064: [IP Masking] Maintenance script to rename users matching configured TempUser pattern