In Wikibase, we are trying to use the mw.Api.assertCurrentUser() method to ensure that users don’t accidentally edit after logging out in another tab. However, we noticed a problem: if the user loads the page while logged out, then makes an edit that creates a temporary account for them, and then tries to make a second edit without reloading the page, assertCurrentUser() will add a parameter assert=anon, and the second API request will fail because the session is no longer anonymous.
I believe this is a general assertCurrentUser() problem that should be fixed in that method, though it currently doesn’t seem to be reproducible elsewhere: the method is used relatively rarely according to codesearch, and the issue described above doesn’t seem to be reproducible in any of the other places that use it (except maybe Wikidata Bridge, but I haven’t tried it there). Special:NewLexeme always redirects after an edit, the ConvenientDiscussions gadget can’t be used by anons, Flow disallows anonymous editing if temporary accounts are enabled, and CommunityRequests doesn’t seem to allow anonymous voting either.
Alternatively, we could work around the problem with assertCurrentUser() in Wikibase by not using it (compare the legacy desktop UI), or only using it if the user is logged in. But that would run counter to how assertCurrentUser() is supposed to be used, and it seems a shame to have a method in MediaWiki core that’s not fit for its intended purpose.
Note that, in Wikimedia production, this problem wouldn’t really occur if the API is used correctly, because the API response for any request that created a temporary account should include some kind of redirect URL to finish setting up the account in CentralAuth (compare T357020), and once the user has finished following the redirect and ended up back where they started, assertCurrentUser() will know that they’re “logged in” with a temp account, so it would no longer send the incorrect assert=anon parameter. But this only applies to wikis with CentralAuth installed (or other extensions with a TempUserCreatedRedirect hook handler), so generally speaking the assertCurrentUser() shipped by MediaWiki core still has a problem.