mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-24 22:35:41 +00:00
Fix the "you are now logged in/out" warning
It would tell you you were logged out when you were actually logged in, and when I looked into it, I found lots of broken things, including lots of confusion between the current anon-ness and username and the new anon-ness and username. ve.init.mw.Target: * Check the new isAnon value, not the old one * Pass the username to the event, rather than just anon-ness ve.init.mw.ViewPageTarget: * Use the passed username (new username) rather than the username from mw.config (which is updated, but confusing) Change-Id: Icf406d49100d81e87c677fd6b57ff93cc29f601f
This commit is contained in:
parent
bc031a78ba
commit
9b3316a360
|
@ -560,17 +560,16 @@ ve.init.mw.ViewPageTarget.prototype.onSaveErrorBadToken = function () {
|
|||
* 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() ) )
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -652,7 +651,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
|
||||
|
@ -661,6 +660,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 } );
|
||||
|
@ -670,10 +670,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;
|
||||
|
|
Loading…
Reference in a new issue