- currentRequest = currentRequestInternal = checkUsername( username ).done( function ( info ) {
- var message;
-
- // Another request was fired in the meantime, the result we got here is no longer current.
- // This shouldn't happen as we abort pending requests, but you never know.
- if ( currentRequest !== currentRequestInternal ) {
- return;
- }
- // If we're here, then the current request has finished, avoid calling .abort() needlessly.
- currentRequest = undefined;
-
- if ( info.state === 'ok' ) {
- clearStatus();
- } else {
- if ( info.state === 'invalid' ) {
- message = mw.message( 'noname' ).text();
- } else if ( info.state === 'taken' ) {
- message = mw.message( 'userexists' ).text();
- }
+ apiPromise = api.post( {
+ action: 'validatepassword',
+ user: $usernameInput.val(),
+ password: $passwordInput.val(),
+ email: $emailInput.val() || '',
+ realname: $realNameInput.val() || '',
+ formatversion: 2,
+ errorformat: 'html',
+ errorsuselocal: true,
+ uselang: mw.config.get( 'wgUserLanguage' )
+ } )
+ .done( function ( resp ) {
+ var pwinfo = resp.validatepassword || {};
+
+ d.resolve( {
+ valid: pwinfo.validity === 'Good',
+ messages: pwinfo.validitymessages ? pwinfo.validitymessages.map( function ( m ) {
+ return m.html;
+ } ) : []
+ } );
+ } )
+ .fail( d.reject );