ajaxOptions = undefined;
}
- return api.getToken( tokenType ).then( function ( token ) {
+ return api.getToken( tokenType, params.assert ).then( function ( token ) {
params.token = token;
return api.post( params, ajaxOptions ).then(
// If no error, return to caller as-is
params.token = undefined;
// Try again, once
- return api.getToken( tokenType ).then( function ( token ) {
+ return api.getToken( tokenType, params.assert ).then( function ( token ) {
params.token = token;
return api.post( params, ajaxOptions );
} );
/**
* Get a token for a certain action from the API.
*
+ * The assert parameter is only for internal use by postWithToken.
+ *
* @param {string} type Token type
* @return {jQuery.Promise}
* @return {Function} return.done
* @return {string} return.done.token Received token.
* @since 1.22
*/
- getToken: function ( type ) {
+ getToken: function ( type, assert ) {
var apiPromise,
promiseGroup = promises[ this.defaults.ajax.url ],
d = promiseGroup && promiseGroup[ type + 'Token' ];
if ( !d ) {
- apiPromise = this.get( { action: 'tokens', type: type } );
+ apiPromise = this.get( { action: 'tokens', type: type, assert: assert } );
d = apiPromise
.then( function ( data ) {