mirror of https://github.com/vector-im/riot-web
Store mx_pass at the same point as access_token
So that we don't overwrite the existing one every time we try to register.pull/21833/head
parent
a887af9f92
commit
4f71f4c331
|
@ -303,6 +303,12 @@ export function setLoggedIn(credentials) {
|
||||||
localStorage.setItem("mx_device_id", credentials.deviceId);
|
localStorage.setItem("mx_device_id", credentials.deviceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The user registered as a PWLU (PassWord-Less User), the generated password
|
||||||
|
// is cached here such that the user can change it at a later time.
|
||||||
|
if (credentials.password) {
|
||||||
|
localStorage.setItem("mx_pass", credentials.password);
|
||||||
|
}
|
||||||
|
|
||||||
console.log("Session persisted for %s", credentials.userId);
|
console.log("Session persisted for %s", credentials.userId);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.warn("Error using local storage: can't persist session!", e);
|
console.warn("Error using local storage: can't persist session!", e);
|
||||||
|
|
|
@ -56,21 +56,18 @@ export default React.createClass({
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
_generateAndCachePassword: function() {
|
_generatePassword: function() {
|
||||||
const pass = Math.random().toString(36).slice(2);
|
return Math.random().toString(36).slice(2);
|
||||||
if (localStorage) {
|
|
||||||
localStorage.setItem('mx_pass', pass);
|
|
||||||
}
|
|
||||||
return pass;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
_makeRegisterRequest: function(auth) {
|
_makeRegisterRequest: function(auth) {
|
||||||
// Not upgrading - changing mxids
|
// Not upgrading - changing mxids
|
||||||
const guestAccessToken = null;
|
const guestAccessToken = null;
|
||||||
|
this._generatedPassword = this._generatePassword();
|
||||||
|
|
||||||
return this._matrixClient.register(
|
return this._matrixClient.register(
|
||||||
this.state.username,
|
this.state.username,
|
||||||
this._generateAndCachePassword(),
|
this._generatedPassword,
|
||||||
undefined, // session id: included in the auth dict already
|
undefined, // session id: included in the auth dict already
|
||||||
auth,
|
auth,
|
||||||
{},
|
{},
|
||||||
|
@ -98,6 +95,7 @@ export default React.createClass({
|
||||||
homeserverUrl: this._matrixClient.getHomeserverUrl(),
|
homeserverUrl: this._matrixClient.getHomeserverUrl(),
|
||||||
identityServerUrl: this._matrixClient.getIdentityServerUrl(),
|
identityServerUrl: this._matrixClient.getIdentityServerUrl(),
|
||||||
accessToken: response.access_token,
|
accessToken: response.access_token,
|
||||||
|
password: this._generatedPassword,
|
||||||
teamToken: teamToken,
|
teamToken: teamToken,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue