From 74b222230da8a3dadc4d03e1a3e000c1ca09e12a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bartosz=20Dziewo=C5=84ski?= Date: Fri, 7 Mar 2014 18:39:51 +0100 Subject: [PATCH] Check validity and availability of usernames during signup via AJAX MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This is done in addition to the server-side checks. Users who have disabled JavaScript will not notice any difference. The way this is done (via action=query&list=users API) means that we can't check for all possible error conditions, both for the username (e.g. these enforced by extensions like AntiSpoof) and other parts of the form (e-mail, password…) – these are still handled server-side only. Thus we intentionally never say that whatever the user typed in is valid – we only warn when we know it's not. Doing this "properly" would require some reworking of the internals of the signup process and this way is already a huge improvement. (Split off from the reverted a0c72523.) Bug: 34447 Change-Id: I42c00b54651fd4e7217a862b3116c6113935f5ae --- RELEASE-NOTES-1.23 | 2 + includes/templates/Usercreate.php | 12 +- resources/Resources.php | 9 +- .../mediawiki.special.userlogin.signup.js | 112 +++++++++++++++++- 4 files changed, 129 insertions(+), 6 deletions(-) diff --git a/RELEASE-NOTES-1.23 b/RELEASE-NOTES-1.23 index 2b91f88f88..b24442056e 100644 --- a/RELEASE-NOTES-1.23 +++ b/RELEASE-NOTES-1.23 @@ -116,6 +116,8 @@ production. creations, similar to the topOnly option. * Add mediawiki.ui.button styling to all pages so wiki content can use styled buttons. +* Special:UserLogin/signup now does AJAX checks for invalid and taken usernames, + displaying the error live. === Bug fixes in 1.23 === * (bug 41759) The "updated since last visit" markers (on history pages, recent diff --git a/includes/templates/Usercreate.php b/includes/templates/Usercreate.php index 0cb83d555e..aba0d2767c 100644 --- a/includes/templates/Usercreate.php +++ b/includes/templates/Usercreate.php @@ -58,15 +58,23 @@ class UsercreateTemplate extends BaseTemplate {
html( 'header' ); /* extensions such as ConfirmEdit add form HTML here */ ?>
+ +
data['message'] ) { ?> + class="data['messagetype']; ?>box" + + style="display: none;" + + > data['message'] ) { ?> -
data['messagetype'] == 'error' ) { ?> msg( 'createacct-error' ); ?>
html( 'message' ); ?> -
+