MarkTraceur has uploaded a new change for review. https://gerrit.wikimedia.org/r/224950
Change subject: Add a bailout method for getEditToken ...................................................................... Add a bailout method for getEditToken getEditToken is right handy for doing requests on the local wiki, but CentralAuth yells at you if you leave a token= parameter in the request, so we need to be able to turn this off. Change-Id: I6212c6aa2f52671f22e227950a37dde6b65d5316 --- M resources/src/mediawiki.api/mediawiki.api.upload.js 1 file changed, 24 insertions(+), 10 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/50/224950/1 diff --git a/resources/src/mediawiki.api/mediawiki.api.upload.js b/resources/src/mediawiki.api/mediawiki.api.upload.js index f147ac8..aceeccd 100644 --- a/resources/src/mediawiki.api/mediawiki.api.upload.js +++ b/resources/src/mediawiki.api/mediawiki.api.upload.js @@ -224,9 +224,11 @@ return $.Deferred().reject( 'Filename not included in file data.' ); } - tokenPromise = this.getEditToken().then( function ( token ) { - $form.append( getHiddenInput( 'token', token ) ); - } ); + if ( this.needToken() ) { + tokenPromise = this.getEditToken().then( function ( token ) { + $form.append( getHiddenInput( 'token', token ) ); + } ); + } $( 'body' ).append( $form, $iframe ); @@ -286,13 +288,15 @@ xhr.open( 'POST', this.defaults.ajax.url, true ); - tokenPromise = this.getEditToken().then( function ( token ) { - formData.append( 'token', token ); - xhr.send( formData ); - }, function () { - // Mark the edit token as bad, it's been used. - api.badToken( 'edit' ); - } ); + if ( this.needToken() ) { + tokenPromise = this.getEditToken().then( function ( token ) { + formData.append( 'token', token ); + xhr.send( formData ); + }, function () { + // Mark the edit token as bad, it's been used. + api.badToken( 'edit' ); + } ); + } return deferred.promise(); }, @@ -349,6 +353,16 @@ return finishUpload; } ); + }, + + /** + * Whether we need a token for this upload process. + * Override and return false if you're doing a request based on a + * CentralAuth token, or other method of validation. + * @return {boolean} + */ + needToken: function () { + return true; } } ); -- To view, visit https://gerrit.wikimedia.org/r/224950 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I6212c6aa2f52671f22e227950a37dde6b65d5316 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: MarkTraceur <mtrac...@member.fsf.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits