Page MenuHomePhabricator

[MEX] - support temporary accounts correctly
Closed, ResolvedPublic

Description

In order to correctly support temporary accounts (aka IP Masking) when editing, the new mobile editing experience (aka wbui2025) needs to:

  • send returnto, returntoquery and/or returntoanchor URL parameters with API requests that make edits
  • if the API responds with a tempuserredirect URL, redirect the user to that URL to finish setting up the account (e.g. for CentralAuth)

See also T357020: [DOT] Perform necessary redirects after creating temporary account in Wikidata-related extensions.

Acceptance Criteria

  • Temporary accounts are supported when editors are editing statements in the new mobile editing experience
  • If the API responds with a tempuserredirect URL, redirect the user to that URL to finish setting up the account (e.g. for CentralAuth)

Details

Related Changes in Gerrit:

Event Timeline

Change #1202085 had a related patch set uploaded (by Mahmoud-abdelsattar; author: Mahmoud-abdelsattar):

[mediawiki/extensions/Wikibase@master] [WIP] Supporting the temp accounts

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

🔄 Development Handover Summary

NOTE: 🟢 Move from "In Development" > "Ready for Peer Review"

📋 Overview

Implementing the temp accounts created redirect support when editing the new mobile editing experience.

✅ Work Completed

  • Temporary accounts are supported when editors are editing statements in the new mobile editing experience
  • If the API responds with a tempuserredirect URL, redirect the user to that URL to finish setting up the account (e.g. for CentralAuth)
  • Jest tests are covering the tempUserCreated logic.

🧪 Testing/Technical Status

Completed:

  • Jest tests
  • Manual testing performed
  • CI Builds are green and no merge conflicts (so far)
  • E2E tests written and passing (Will have to pass for this tempUser topic due to different implementations between the production, CI and local)
  • Code review received
  • Code review comments addressed and resolved

Test Coverage:

  • addReturnToParams() adds full returnto fields, omits missing values, and leaves the original params untouched.
  • handleTempUserRedirect() redirects when tempuserredirect exists and preserves the URL otherwise.
  • checkAndHandleTempUserRedirect() triggers the popup when redirected-by-hook=yes is present and skips it for empty queries or redirected-by-hook=no.

🔗 Related Resources

  • Related Gerrit Patch(s):

https://gerrit.wikimedia.org/r/c/1202085

🎯 How to test:

  1. For localhost testing, you will need to add the following code snippet to your LocalSettings.php file in order to enable the tempUserCreatedRedirect:
$wgHooks['TempUserCreatedRedirect'][] = static function (
		\MediaWiki\Session\Session $session,
		\MediaWiki\User\UserIdentity $user,
		string $returnTo,
		string $returnToQuery,
		string $returnToAnchor,
		&$redirectUrl
	) {
		if ( $returnTo === '' ) {
			$returnTo = \MediaWiki\Title\Title::newMainPage()->getFullText();
		}
		if ( $returnToQuery === '' ) {
			$returnToQuery = 'redirected-by-hook=yes';
		} else {
			$returnToQuery = "redirected-by-hook=yes&$returnToQuery";
		}
		$redirectUrl = \MediaWiki\Title\Title::newFromTextThrow( $returnTo )
				->getFullURL( $returnToQuery ) . $returnToAnchor;
	};

📸 Screenshots

image.png (1×520 px, 81 KB)


Handover Date: 10th November 2025
Last Updated By: Mahmoud

Change #1202085 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] Supporting the temp accounts

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