Patch for allowing user_name OR user_email authentication on Wikipedia
Can't authenticate using my mother language username (UNICODE) when I only have (a public) access to Wikipedia with an ASCII (english) keyboard
This is a real issue for people who have registered with a username having UNICODE and non ASCII (7 bits) characters and who want to login to Wikipedia when they are abroad with a simple English keyboard and want to edit some pages (usually English pages).
The fact that Wikipedia and Mediawikis do not offer the possibility to authenticate with an e-mail is now considered, at least for me, as a bug.
I recently discussed this fact on Wikitech-l ("Great idea" http://lists.wikimedia.org/pipermail/wikitech-l/2012-February/058183.html) and some tests have been made trying to answer legitimate questions (see http://lists.wikimedia.org/pipermail/wikitech-l/2012-February/058253.html) to a simple patch that I proposed.
This small patch in User.php (function idFromName) is enough in most cases:
$dbr = wfGetDB( DB_SLAVE ); $s = $dbr->selectRow( 'user', array( 'user_id' ), array( 'user_name' => $nt->getText() ), __METHOD__ ); if ( $s === false ) { //Start Patch $result = null; $stwo = $dbr->selectRow( 'user', array( 'user_id' ), array( 'user_email' => $nt->getText() ), __METHOD__ ); if ( $stwo === false ) { $result = null; }else { $result = $stwo->user_id; } //End Patch } else { $result = $s->user_id; }
The modified Login form is:
Username (or e-mail): |___________________|
Password: |___________________|
The full attached patch is rendering this new form in about 20 languages (that is what we need in our wikis). The patch is simply adding two new msg:
- 'yournameoremail' instead of 'yourname' in Userlogin.php and
- 'passwordreset-usernameoremail' instead of 'passwordreset-username' in SpecialPasswordReset.php .
In order to explain this new experimental feature, we added a Hook in LocalSettings.php :
function efLoginFormMessage( &$template ) {
$template->set( 'header', "NEW (experimental): if you are a registered user with an authenticated e-mail, you can also log in with your e-mail address in place of your username. Your e-mail is used only during the authentication phase; if successful you will be logged with your standard username. <br />Please notice that for people owning different accounts with the same e-mail, you will be logged in with your first registered username (lowest ID). If the password entered doesn't match the password of your lowest registered ID, you can't authenticate this way and should enter your desired username."); return true;
}
$wgHooks['UserLoginForm'][]='efLoginFormMessage';
I hope that this patch will be visited and accept. It is changing our live here. People having been registered with accented characters or in Cyrillic can use their e-mail to get their temporary password by e-mail while still being able to sign authorship in Cyrillic or with accented characters avoiding the English transliteration. Others still prefer the English transliteration, it is a question of taste.
Without this patch, people are using the English transliteration for the commodity of authentication.
Regards,
Version: 1.18.x
Severity: normal
See Also:
T30085: RFC: Allow user login with email address in addition to username
T15097: Deploy ULS/UniversalLanguageSelector to all Wikimedia wikis (tracking)
attachment languagesb181b.patch ignored as obsolete