Merge "Fix the "you are now logged in/out" warning"

This commit is contained in:
jenkins-bot 2014-11-25 00:19:14 +00:00 committed by Gerrit Code Review
commit 35cbae3d76
2 changed files with 8 additions and 10 deletions

View file

@ -573,17 +573,16 @@ ve.init.mw.ViewPageTarget.prototype.onSaveErrorAbuseFilter = function ( editApi
* Update save dialog when token fetch indicates another user is logged in
*
* @method
* @param {boolean|undefined} isAnon Is newly logged in user anonymous. If
* undefined, user is logged in
* @param {string|null} username Name of newly logged-in user, or null if anonymous
*/
ve.init.mw.ViewPageTarget.prototype.onSaveErrorNewUser = function ( isAnon ) {
ve.init.mw.ViewPageTarget.prototype.onSaveErrorNewUser = function ( username ) {
var badToken, userMsg;
badToken = document.createTextNode( mw.msg( 'visualeditor-savedialog-error-badtoken' ) + ' ' );
// mediawiki.jqueryMsg has a bug with [[User:$1|$1]] (bug 51388)
if ( isAnon ) {
if ( username === null ) {
userMsg = 'visualeditor-savedialog-identify-anon';
} else {
userMsg = 'visualeditor-savedialog-identify-user---' + mw.config.get( 'wgUserName' );
userMsg = 'visualeditor-savedialog-identify-user---' + username;
}
this.showSaveError(
$( badToken ).add( $.parseHTML( mw.message( userMsg ).parse() ) )

View file

@ -125,8 +125,7 @@ OO.inheritClass( ve.init.mw.Target, ve.init.Target );
/**
* @event saveErrorNewUser
* Fired when user is logged in as a new user
* @param {boolean|undefined} isAnon Is newly logged in user anonymous. If
* undefined, user is logged in
* @param {string|null} username Name of newly logged-in user, or null if anonymous
*/
/**
@ -660,7 +659,7 @@ ve.init.mw.Target.prototype.onSaveError = function ( doc, saveData, jqXHR, statu
viewPage.save( doc, saveData );
} else {
// The now current session is a different user
if ( isAnon ) {
if ( userInfo.anon !== undefined ) {
// New session is an anonymous user
mw.config.set( {
// wgUserId is unset for anonymous users, not set to null
@ -669,6 +668,7 @@ ve.init.mw.Target.prototype.onSaveError = function ( doc, saveData, jqXHR, statu
// functions like mw.user.isAnon rely on this.
wgUserName: null
} );
viewPage.emit( 'saveErrorNewUser', null );
} else {
// New session is a different user
mw.config.set( { wgUserId: userInfo.id, wgUserName: userInfo.name } );
@ -678,10 +678,9 @@ ve.init.mw.Target.prototype.onSaveError = function ( doc, saveData, jqXHR, statu
mw.messages.get( 'visualeditor-savedialog-identify-user' )
.replace( /\$1/g, userInfo.name )
);
viewPage.emit( 'saveErrorNewUser', userInfo.name );
}
viewPage.emit( 'saveErrorNewUser', isAnon );
}
}
} );
return;