From 80cddf549c302a17dc241f19fcaadc29653d2cda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartosz=20Dziewo=C5=84ski?= Date: Sat, 15 Feb 2020 03:01:31 +0100 Subject: [PATCH] Use built-in mw.Api 'badtoken' handling, also 'assert'/'assertuser' This ensures that expired tokens are refreshed and retried, while invalid tokens caused by the user logging in/out cause an error. We should think about displaying a better interface for the latter case. Bug: T245327 Depends-On: I485f99e1f5f493262b0c9af22370da01adf1e09c Change-Id: Ibc097ed68e3ae72223b0680ee8895f7884399958 --- modules/controller.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/controller.js b/modules/controller.js index a399c0c5e..8d16c1eba 100644 --- a/modules/controller.js +++ b/modules/controller.js @@ -107,7 +107,8 @@ function postReply( widget, parsoidData ) { basetimestamp: pageData.baseTimeStamp, starttimestamp: pageData.startTimeStamp, etag: pageData.etag, - token: pageData.token, + assert: mw.user.isAnon() ? 'anon' : 'user', + assertuser: mw.user.getName() || undefined, // This appears redundant currently, but as editing / new-topics get added, we'll expand it dttags: [ 'discussiontools', 'discussiontools-reply', 'discussiontools-' + widget.mode ].join( ',' ) } @@ -160,8 +161,7 @@ function init( $container, state ) { repliedToComment, parsoidPageData = { pageName: mw.config.get( 'wgRelevantPageName' ), - oldId: mw.config.get( 'wgRevisionId' ), - token: mw.user.tokens.get( 'csrfToken' ) + oldId: mw.config.get( 'wgRevisionId' ) }; state = state || {};