Skip to content

Avoid logout when loginError caused by network error

Gary Wang requested to merge garywang/neochat:avoid-unintended-logout into master

Quoted from @kitsune:matrix.org:

Ok, here's the sequence of events: AccountRegistry goes through the accounts found in the client configuration, and for each with a configured homeserver and access token it picks the access token and triggers Connection::assumeIdentity(). One of the first things this method does is validating the access token by calling the token owner request. Without the network, this request obviously fails; unlike the normal login sequence though, the handler for this failure (still within Connection::assumeIdentity()) doesn't discern between network issues and a token refusal; it just fires loginError(), which is not right. Now we go to the NeoChat code, namely Controller::invokeLogin() that calls Controller::logout() upon encountering Connection::loginError() (this is not right either: loginError() kind of implies that the user is not logged in). Controller::logout() does not only log out the session (if any), it also deletes the access token from the client configuration. Curtain call.

This patch avoid calling logout() when loginError() was fired due to network issue like homeserver downtime or user network downtime. Now it will stuck at the login loading screen forever but at least the login information/token(s) won't get deleted in this unintended way.

BUG: 464397

btw, we might need a way to better support this edge case so users who uses multiple account will still able to use the other accounts if one of their accounts' homeserver is down, and they may re-try login when that account's homeserver is back online.

Merge request reports