From a85259c2b790e2371ec12da9be6a5ef7a7dffa2d Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Wed, 10 Aug 2016 23:52:09 +0100 Subject: [PATCH] Fix session persistence https://github.com/matrix-org/matrix-react-sdk/pull/404 messed this up somewhat; hopefully this gets it right --- src/Lifecycle.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/Lifecycle.js b/src/Lifecycle.js index 0ccf628206..5c2dd1e208 100644 --- a/src/Lifecycle.js +++ b/src/Lifecycle.js @@ -165,15 +165,13 @@ export function setLoggedIn(credentials) { // persist the session if (localStorage) { try { - localStorage.setItem("mx_hs_url", hs_url); - localStorage.setItem("mx_is_url", is_url); + localStorage.setItem("mx_hs_url", credentials.homseserverUrl); + localStorage.setItem("mx_is_url", credentials.identityServerUrl); - if (user_id !== undefined && access_token !== undefined) { - localStorage.setItem("mx_user_id", user_id); - localStorage.setItem("mx_access_token", access_token); - localStorage.setItem("mx_is_guest", JSON.stringify(isGuest)); - console.log("Session persisted for %s", user_id); - } + localStorage.setItem("mx_user_id", credentials.userId); + localStorage.setItem("mx_access_token", credentials.accessToken); + localStorage.setItem("mx_is_guest", JSON.stringify(credentials.guest)); + console.log("Session persisted for %s", credentials.userId); } catch (e) { console.warn("Error using local storage: can't persist session!", e); }