Page MenuHomePhabricator

Create a function that checks if the global session user is a temporary user in JS
Closed, ResolvedPublic

Description

An equivalent of user::isTemp() is needed is JS.

AC

  • Create a function that checks if user is a temporary user
  • Create tests for the created function

Event Timeline

@tstarling Are we correct that this hasn't been implemented yet? We haven't been able to find it.

@tstarling Are we correct that this hasn't been implemented yet? We haven't been able to find it.

Change 882593 had a related patch set uploaded (by Kosta Harlan; author: Kosta Harlan):

[mediawiki/core@master] mediawiki.user: Add methods for isNamed and isTemp

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

@tstarling Are we correct that this hasn't been implemented yet? We haven't been able to find it.

I did not see that either, so added the isTemp/isNamed methods to mediawiki.user in the above patch, as I think we'll be wanting those in GrowthExperiments.

Create tests for the created function

I didn't write any tests though, sorry!

Tchanders renamed this task from Create a function that checks if user is a temporary user in JS to Create a function that checks if the global session user is a temporary user in JS.Jan 24 2023, 3:23 PM

Thank you @kostajh!

@TThoabala I think this task was originally meant for checking whether any user name found in the UI belongs to a named user or a temporary user. The patch does this for the global session user (the user accessing the webpage), and since the task description doesn't differentiate, I think we can just use this task for that instead - so I've updated the title. We do still need this for any user name though, e.g. for T324602: SpecialBlock: Once a temporary account is selected, below the username field display IP addresses associated with the account. Would you be happy to make a task for that?

Change 882593 merged by jenkins-bot:

[mediawiki/core@master] mediawiki.user: Add methods for isNamed and isTemp

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

dom_walden subscribed.

I used the browser console to test the three functions on enwiki and dewiki beta:

mw.user.isNamed()
mw.user.isTemp()
mw.user.isAnon()

for an anonymous user, a temporary user and a logged in user. The functions returned the correct boolean value.

Test environments: