Page MenuHomePhabricator

Handle session expiration in Section Translation
Closed, ResolvedPublic

Description

Unlike Content Translation (T192066), Section Translation does not surface that the session has expired for the user. As a result a user can start translating an article and when publishing, the contents get added associated to the user IP instead without any notice.

This can be tested on the test server by starting a translaiton as logged in user and log-out from a separate window before publishing. The behaviour on production wikis has not been verified.

Even when publishing is allowed for anonymous, we don't want his to happen by surprise, and we should inform of the session expiry.

This ticket proposes to show a dialog like the one used in Content Translation:

CX-error-session-dialog.png (720×1 px, 215 KB)

We may want to adjust the messaging for it to make more sense even for those cases where logged-out editing is allowed:

Your session has expired
Your edits cannot be saved and attributed to your account unless you log in again in another window.
[Log-in]

Implementation details

  1. We want to assert the user, every time the user returns to the application from another window, or tab, i.e. when visibilitychange event is triggered and visibilityState is set to "visible".
  2. We want to assert the user before each router navigation. Since logging out in another window can still go unnoticed if we only implement the previous (1.) item, we want to assert the user before each router navigation, so that we make sure to not let them proceed to next steps in such cases.
  3. We want to assert the user on critical API requests, i.e. auto-saving and publishing requests. We may assert the user in other API calls too, but we'll only display the login dialog for auto-saving and publishing requests, failing with "assertuserfailed" error.

For case (3.) we do not need to send an additional request for the user assertion, we can accomplish that by just adding a parameter to the existing saving and publishing requests. Nevertheless, we need to send extra requests for both (1.) and (2.) cases. To avoid redundant "assert user" requests being sent simultaneously, we should debounce these requests for at least 3 seconds.

Event Timeline

This can be tested on the test server by starting a translaiton as logged in user and log-out from a separate window before publishing. The behaviour on production wikis has not been verified.

In test wiki, we allow anonymous section translation. This is why IP address being associated with publishing after section expire/logout. In production wikis, you will get publishing error. But both of these behaviours are not correct. As the ticket propose, user should be informed.

This ticket proposes to show a dialog like the one used in Content Translation

Just to confirm: Should this be a dialog or along with the message we display about publishing error? Also the login link should take the user to new tab right? Then the user should come back. They should be able to dismiss the dialog/message(or the dialog should get closed when "log in" link is clicked

This ticket proposes to show a dialog like the one used in Content Translation

Just to confirm: Should this be a dialog or along with the message we display about publishing error? Also the login link should take the user to new tab right? Then the user should come back. They should be able to dismiss the dialog/message(or the dialog should get closed when "log in" link is clicked

The idea is to show a dialog that can be shown at the editor but also at the dashboard. Logging should take place on a new tab. For closing the dialog the following approach was proposed for desktop that we can try to follow here too:

  • In the background, regular checks are made to verify if the issue still happens. If the issue is no longer happening, the dialog gets closed. We may want to pay special attention to the visibility change event to check if the user logged-in after returning from the other window.

Change 922891 had a related patch set uploaded (by Nik Gkountas; author: Nik Gkountas):

[mediawiki/extensions/ContentTranslation@master] SX: Handle session expiration

https://gerrit.wikimedia.org/r/922891

Change 922891 merged by jenkins-bot:

[mediawiki/extensions/ContentTranslation@master] SX: Handle session expiration

https://gerrit.wikimedia.org/r/922891

@ngkountas

two scenarios tested here. I signed out in the same windwow but different tab and I go the warning. In the second scenario I logged out while in a different window and I was able to continue translation and also published. If this implementation confised to being in one window ?

Ideally it should work in both scenarios.
@ngkountas may be able to confirm when the check for session status is performed and whether it is connected to an event that may be different depending on whether a tab or a window gets the focus or this may be due to something else. Based on that, we can consider a follow-up ticket if needed.

Change 954107 had a related patch set uploaded (by Nik Gkountas; author: Nik Gkountas):

[mediawiki/extensions/ContentTranslation@master] SX: Assert user before each router navigation

https://gerrit.wikimedia.org/r/954107

Change 954108 had a related patch set uploaded (by Nik Gkountas; author: Nik Gkountas):

[mediawiki/extensions/ContentTranslation@master] SX: Create AssertUserError and use it

https://gerrit.wikimedia.org/r/954108

Change 954109 had a related patch set uploaded (by Nik Gkountas; author: Nik Gkountas):

[mediawiki/extensions/ContentTranslation@master] SX: Add user assertion to auto save and publish requests

https://gerrit.wikimedia.org/r/954109

One thing I noticed is that the dialog is dismiss-able if the user clicks outside the dialog window. I think this is fine since the user makes a choice, willingly, to ignore the warning we gave them, but just something to keep in mind.

Change 954107 merged by jenkins-bot:

[mediawiki/extensions/ContentTranslation@master] SX: Assert user before each router navigation

https://gerrit.wikimedia.org/r/954107

Change 954108 merged by jenkins-bot:

[mediawiki/extensions/ContentTranslation@master] SX: Create AssertUserError and use it

https://gerrit.wikimedia.org/r/954108

One thing I noticed is that the dialog is dismiss-able if the user clicks outside the dialog window. I think this is fine since the user makes a choice, willingly, to ignore the warning we gave them, but just something to keep in mind.

Thanks for flagging this, Abijeet.
I think it may be preferred not to have the dialog as dismissible. Letting the user in a state were the contents cannot be published or can be misleadingly published under a different name can be problematic, and handling error situations later may add more complexity (technical and for the user).

If this is a complex adjustments, we can create a follow-up ticket.

Change 954109 merged by jenkins-bot:

[mediawiki/extensions/ContentTranslation@master] SX: Add user assertion to auto save and publish requests

https://gerrit.wikimedia.org/r/954109

Change 962059 had a related patch set uploaded (by Nik Gkountas; author: Nik Gkountas):

[mediawiki/extensions/ContentTranslation@master] CX3 Build 0.2.0+20230929

https://gerrit.wikimedia.org/r/962059

Change 962059 merged by jenkins-bot:

[mediawiki/extensions/ContentTranslation@master] CX3 Build 0.2.0+20230929

https://gerrit.wikimedia.org/r/962059

Change 965483 had a related patch set uploaded (by Nik Gkountas; author: Nik Gkountas):

[mediawiki/extensions/ContentTranslation@master] SX Login Dialog: Do not close when clicking on overlay or pressing ESC

https://gerrit.wikimedia.org/r/965483

Change 965483 merged by jenkins-bot:

[mediawiki/extensions/ContentTranslation@master] SX Login Dialog: Do not close when clicking on overlay or pressing ESC

https://gerrit.wikimedia.org/r/965483

Change 969073 had a related patch set uploaded (by Nik Gkountas; author: Nik Gkountas):

[mediawiki/extensions/ContentTranslation@master] CX3 Build 0.2.0+20231026

https://gerrit.wikimedia.org/r/969073

Change 969073 merged by jenkins-bot:

[mediawiki/extensions/ContentTranslation@master] CX3 Build 0.2.0+20231026

https://gerrit.wikimedia.org/r/969073

Change 968776 had a related patch set uploaded (by KartikMistry; author: Nik Gkountas):

[mediawiki/extensions/ContentTranslation@wmf/1.42.0-wmf.2] CX3 Build 0.2.0+20231026

https://gerrit.wikimedia.org/r/968776

Change 968777 had a related patch set uploaded (by KartikMistry; author: Nik Gkountas):

[mediawiki/extensions/ContentTranslation@wmf/1.42.0-wmf.1] CX3 Build 0.2.0+20231026

https://gerrit.wikimedia.org/r/968777

Change 968777 merged by jenkins-bot:

[mediawiki/extensions/ContentTranslation@wmf/1.42.0-wmf.1] CX3 Build 0.2.0+20231026

https://gerrit.wikimedia.org/r/968777

Mentioned in SAL (#wikimedia-operations) [2023-10-26T13:31:10Z] <lucaswerkmeister-wmde@deploy2002> Started scap: Backport for [[gerrit:968777|CX3 Build 0.2.0+20231026 (T348563 T308836)]]

Mentioned in SAL (#wikimedia-operations) [2023-10-26T13:32:30Z] <lucaswerkmeister-wmde@deploy2002> lucaswerkmeister-wmde and kartik: Backport for [[gerrit:968777|CX3 Build 0.2.0+20231026 (T348563 T308836)]] synced to the testservers (https://wikitech.wikimedia.org/wiki/Mwdebug)

Mentioned in SAL (#wikimedia-operations) [2023-10-26T13:45:58Z] <lucaswerkmeister-wmde@deploy2002> Finished scap: Backport for [[gerrit:968777|CX3 Build 0.2.0+20231026 (T348563 T308836)]] (duration: 14m 48s)

Change 968776 merged by jenkins-bot:

[mediawiki/extensions/ContentTranslation@wmf/1.42.0-wmf.2] CX3 Build 0.2.0+20231026

https://gerrit.wikimedia.org/r/968776

Mentioned in SAL (#wikimedia-operations) [2023-10-26T14:38:16Z] <lucaswerkmeister-wmde@deploy2002> Started scap: Backport for [[gerrit:968776|CX3 Build 0.2.0+20231026 (T348563 T308836)]]

Mentioned in SAL (#wikimedia-operations) [2023-10-26T14:39:36Z] <lucaswerkmeister-wmde@deploy2002> kartik and lucaswerkmeister-wmde: Backport for [[gerrit:968776|CX3 Build 0.2.0+20231026 (T348563 T308836)]] synced to the testservers (https://wikitech.wikimedia.org/wiki/Mwdebug)

Mentioned in SAL (#wikimedia-operations) [2023-10-26T14:52:18Z] <lucaswerkmeister-wmde@deploy2002> Finished scap: Backport for [[gerrit:968776|CX3 Build 0.2.0+20231026 (T348563 T308836)]] (duration: 14m 01s)

Session expiration is now handled properly both when switching tabs or windows. The login dialog is also not dismissable any more. This task can be considered done.

Screencasts from greek (el) production wiki: