incorporate keganfeedback
parent
a82d3710d1
commit
893e338917
|
@ -35,7 +35,7 @@ function deviceId() {
|
|||
return id;
|
||||
}
|
||||
|
||||
function createClient(hs_url, is_url, user_id, access_token, guestAccess) {
|
||||
function createClientForPeg(hs_url, is_url, user_id, access_token, guestAccess) {
|
||||
var opts = {
|
||||
baseUrl: hs_url,
|
||||
idBaseUrl: is_url,
|
||||
|
@ -69,7 +69,7 @@ if (localStorage) {
|
|||
var guestAccess = new GuestAccess(localStorage);
|
||||
if (access_token && user_id && hs_url) {
|
||||
console.log("Restoring session for %s", user_id);
|
||||
createClient(hs_url, is_url, user_id, access_token, guestAccess);
|
||||
createClientForPeg(hs_url, is_url, user_id, access_token, guestAccess);
|
||||
}
|
||||
else {
|
||||
console.log("Session not found.");
|
||||
|
@ -92,7 +92,7 @@ class MatrixClient {
|
|||
|
||||
// FIXME, XXX: this all seems very convoluted :(
|
||||
//
|
||||
// if we replace the singleton using URLs we bypass our createClient()
|
||||
// if we replace the singleton using URLs we bypass our createClientForPeg()
|
||||
// global helper function... but if we replace it using
|
||||
// an access_token we don't?
|
||||
//
|
||||
|
@ -102,7 +102,6 @@ class MatrixClient {
|
|||
// -matthew
|
||||
|
||||
replaceUsingUrls(hs_url, is_url) {
|
||||
// ...not to be confused with MatrixClientPeg's createClient...
|
||||
matrixClient = Matrix.createClient({
|
||||
baseUrl: hs_url,
|
||||
idBaseUrl: is_url
|
||||
|
@ -130,8 +129,7 @@ class MatrixClient {
|
|||
}
|
||||
}
|
||||
this.guestAccess.markAsGuest(Boolean(isGuest));
|
||||
// ...not to be confused with Matrix.createClient()...
|
||||
createClient(hs_url, is_url, user_id, access_token, this.guestAccess);
|
||||
createClientForPeg(hs_url, is_url, user_id, access_token, this.guestAccess);
|
||||
if (localStorage) {
|
||||
try {
|
||||
localStorage.setItem("mx_hs_url", hs_url);
|
||||
|
|
|
@ -118,8 +118,8 @@ module.exports = React.createClass({
|
|||
componentDidMount: function() {
|
||||
this._autoRegisterAsGuest = false;
|
||||
if (this.props.enableGuest) {
|
||||
if (!this.getCurrentHsUrl() || !this.getCurrentIsUrl()) {
|
||||
console.error("Cannot enable guest access: can't determine HS/IS URLs to use");
|
||||
if (!this.getCurrentHsUrl()) {
|
||||
console.error("Cannot enable guest access: can't determine HS URL to use");
|
||||
}
|
||||
else if (this.props.startingQueryParams.client_secret && this.props.startingQueryParams.sid) {
|
||||
console.log("Not registering as guest; registration.");
|
||||
|
@ -182,18 +182,18 @@ module.exports = React.createClass({
|
|||
_registerAsGuest: function() {
|
||||
var self = this;
|
||||
console.log("Doing guest login on %s", this.getCurrentHsUrl());
|
||||
MatrixClientPeg.replaceUsingUrls(
|
||||
this.getCurrentHsUrl(),
|
||||
this.getCurrentIsUrl()
|
||||
);
|
||||
var hsUrl = this.getCurrentHsUrl();
|
||||
var isUrl = this.getCurrentIsUrl();
|
||||
|
||||
MatrixClientPeg.replaceUsingUrls(hsUrl, isUrl);
|
||||
MatrixClientPeg.get().registerGuest().done(function(creds) {
|
||||
console.log("Registered as guest: %s", creds.user_id);
|
||||
self._setAutoRegisterAsGuest(false);
|
||||
self.onLoggedIn({
|
||||
userId: creds.user_id,
|
||||
accessToken: creds.access_token,
|
||||
homeserverUrl: self.getCurrentHsUrl(),
|
||||
identityServerUrl: self.getCurrentIsUrl(),
|
||||
homeserverUrl: hsUrl,
|
||||
identityServerUrl: isUrl,
|
||||
guest: true
|
||||
});
|
||||
}, function(err) {
|
||||
|
@ -214,12 +214,10 @@ module.exports = React.createClass({
|
|||
switch (payload.action) {
|
||||
case 'logout':
|
||||
if (window.localStorage) {
|
||||
// preserve our HS & IS URLs for convenience
|
||||
var hsUrl = this.getCurrentHsUrl();
|
||||
var isUrl = this.getCurrentIsUrl();
|
||||
window.localStorage.clear();
|
||||
window.localStorage.setItem("mx_hs_url", hsUrl);
|
||||
window.localStorage.setItem("mx_is_url", isUrl);
|
||||
// preserve our HS & IS URLs for convenience
|
||||
window.localStorage.setItem("mx_hs_url", this.getCurrentHsUrl());
|
||||
window.localStorage.setItem("mx_is_url", this.getCurrentIsUrl());
|
||||
}
|
||||
Notifier.stop();
|
||||
UserActivity.stop();
|
||||
|
|
Loading…
Reference in New Issue