1
0
mirror of https://github.com/matrix-org/matrix-react-sdk.git synced 2025-07-16 22:01:54 +03:00

Ask for the user's password to rehydrate their soft logged out session

Fixes https://github.com/vector-im/riot-web/issues/10236

The changes to the MatrixClientPeg (assign/start) are to permit the SoftLogout page to access the MatrixClientPeg reliably. This is why assign() is called by Lifecycle as an alternative to start().

Minimal design work has been done here. The majority is deferred to https://github.com/vector-im/riot-web/issues/10262
This commit is contained in:
Travis Ralston
2019-07-04 16:45:40 -06:00
parent f3c6c73329
commit 93872e6fa5
7 changed files with 190 additions and 13 deletions

View File

@ -340,6 +340,25 @@ export function setLoggedIn(credentials) {
return _doSetLoggedIn(credentials, true);
}
/**
* Hydrates an existing session by using the credentials provided. This will
* not clear any local storage, unlike setLoggedIn().
*
* Stops the existing Matrix client (without clearing its data) and starts a
* new one in its place. This additionally starts all other react-sdk services
* which use the new Matrix client.
*
* @param {MatrixClientCreds} credentials The credentials to use
*
* @returns {Promise} promise which resolves to the new MatrixClient once it has been started
*/
export function hydrateSession(credentials) {
stopMatrixClient();
localStorage.removeItem("mx_soft_logout");
_isLoggingOut = false;
return _doSetLoggedIn(credentials, false);
}
/**
* fires on_logging_in, optionally clears localstorage, persists new credentials
* to localstorage, starts the new client.
@ -541,6 +560,7 @@ async function startMatrixClient(startSyncing=true) {
await MatrixClientPeg.start();
} else {
console.warn("Caller requested only auxiliary services be started");
await MatrixClientPeg.assign();
}
// dispatch that we finished starting up to wire up any other bits