mirror of
https://github.com/SchildiChat/element-web.git
synced 2024-10-01 01:26:12 -04:00
Get as far as requesting a token
This commit is contained in:
parent
aacc31b2ce
commit
03d048c06f
@ -24,11 +24,13 @@ var matrixClient = null;
|
|||||||
var localStorage = window.localStorage;
|
var localStorage = window.localStorage;
|
||||||
if (localStorage) {
|
if (localStorage) {
|
||||||
var hs_url = localStorage.getItem("mx_hs_url");
|
var hs_url = localStorage.getItem("mx_hs_url");
|
||||||
|
var is_url = localStorage.getItem("mx_is_url") || 'https://matrix.org';
|
||||||
var access_token = localStorage.getItem("mx_access_token");
|
var access_token = localStorage.getItem("mx_access_token");
|
||||||
var user_id = localStorage.getItem("mx_user_id");
|
var user_id = localStorage.getItem("mx_user_id");
|
||||||
if (access_token && user_id && hs_url) {
|
if (access_token && user_id && hs_url) {
|
||||||
matrixClient = Matrix.createClient({
|
matrixClient = Matrix.createClient({
|
||||||
baseUrl: hs_url,
|
baseUrl: hs_url,
|
||||||
|
idBaseUrl: is_url,
|
||||||
accessToken: access_token,
|
accessToken: access_token,
|
||||||
userId: user_id
|
userId: user_id
|
||||||
});
|
});
|
||||||
@ -44,8 +46,11 @@ module.exports = {
|
|||||||
matrixClient = cli;
|
matrixClient = cli;
|
||||||
},
|
},
|
||||||
|
|
||||||
replaceUsingUrl: function(hs_url) {
|
replaceUsingUrls: function(hs_url, is_url) {
|
||||||
matrixClient = Matrix.createClient(hs_url);
|
matrixClient = Matrix.createClient({
|
||||||
|
baseUrl: hs_url,
|
||||||
|
idBaseUrl: is_url
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ module.exports = {
|
|||||||
return {
|
return {
|
||||||
onHsUrlChanged: function() {},
|
onHsUrlChanged: function() {},
|
||||||
onIsUrlChanged: function() {},
|
onIsUrlChanged: function() {},
|
||||||
default_hs_url: 'https://matrix.org/',
|
default_hs_url: 'http://localhost:8008',
|
||||||
default_is_url: 'https://matrix.org/'
|
default_is_url: 'https://matrix.org/'
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
@ -42,8 +42,14 @@ module.exports = {
|
|||||||
|
|
||||||
onHSChosen: function(ev) {
|
onHSChosen: function(ev) {
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
MatrixClientPeg.replaceUsingUrl(this.refs.serverConfig.getHsUrl());
|
MatrixClientPeg.replaceUsingUrls(
|
||||||
this.setState({hs_url: this.refs.serverConfig.getHsUrl()});
|
this.refs.serverConfig.getHsUrl(),
|
||||||
|
this.refs.serverConfig.getIsUrl()
|
||||||
|
);
|
||||||
|
this.setState({
|
||||||
|
hs_url: this.refs.serverConfig.getHsUrl(),
|
||||||
|
is_url: this.refs.serverConfig.getIsUrl()
|
||||||
|
});
|
||||||
this.setStep("fetch_stages");
|
this.setStep("fetch_stages");
|
||||||
var cli = MatrixClientPeg.get();
|
var cli = MatrixClientPeg.get();
|
||||||
this.setState({busy: true});
|
this.setState({busy: true});
|
||||||
@ -72,12 +78,14 @@ module.exports = {
|
|||||||
// XXX: we assume this means we're logged in, but there could be a next stage
|
// XXX: we assume this means we're logged in, but there could be a next stage
|
||||||
MatrixClientPeg.replace(Matrix.createClient({
|
MatrixClientPeg.replace(Matrix.createClient({
|
||||||
baseUrl: that.state.hs_url,
|
baseUrl: that.state.hs_url,
|
||||||
|
idBaseUrl: that.state.is_url,
|
||||||
userId: data.user_id,
|
userId: data.user_id,
|
||||||
accessToken: data.access_token
|
accessToken: data.access_token
|
||||||
}));
|
}));
|
||||||
var localStorage = window.localStorage;
|
var localStorage = window.localStorage;
|
||||||
if (localStorage) {
|
if (localStorage) {
|
||||||
localStorage.setItem("mx_hs_url", that.state.hs_url);
|
localStorage.setItem("mx_hs_url", that.state.hs_url);
|
||||||
|
localStorage.setItem("mx_is_url", that.state.is_url);
|
||||||
localStorage.setItem("mx_user_id", data.user_id);
|
localStorage.setItem("mx_user_id", data.user_id);
|
||||||
localStorage.setItem("mx_access_token", data.access_token);
|
localStorage.setItem("mx_access_token", data.access_token);
|
||||||
} else {
|
} else {
|
||||||
|
@ -87,7 +87,6 @@ module.exports = {
|
|||||||
|
|
||||||
if (this.savedParams.email != '') {
|
if (this.savedParams.email != '') {
|
||||||
return emailFlow;
|
return emailFlow;
|
||||||
t
|
|
||||||
} else {
|
} else {
|
||||||
return otherFlow;
|
return otherFlow;
|
||||||
}
|
}
|
||||||
@ -95,8 +94,14 @@ t
|
|||||||
|
|
||||||
onInitialStageSubmit: function(ev) {
|
onInitialStageSubmit: function(ev) {
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
MatrixClientPeg.replaceUsingUrl(this.refs.serverConfig.getHsUrl());
|
MatrixClientPeg.replaceUsingUrls(
|
||||||
this.setState({hs_url: this.refs.serverConfig.getHsUrl()});
|
this.refs.serverConfig.getHsUrl(),
|
||||||
|
this.refs.serverConfig.getIsUrl()
|
||||||
|
);
|
||||||
|
this.setState({
|
||||||
|
hs_url: this.refs.serverConfig.getHsUrl(),
|
||||||
|
is_url: this.refs.serverConfig.getIsUrl()
|
||||||
|
});
|
||||||
var cli = MatrixClientPeg.get();
|
var cli = MatrixClientPeg.get();
|
||||||
this.setState({busy: true});
|
this.setState({busy: true});
|
||||||
var self = this;
|
var self = this;
|
||||||
@ -119,7 +124,7 @@ t
|
|||||||
busy: true
|
busy: true
|
||||||
});
|
});
|
||||||
var cli = MatrixClientPeg.get();
|
var cli = MatrixClientPeg.get();
|
||||||
this.savedParams.client_secret = cli.generarteClientSecret();
|
this.savedParams.client_secret = cli.generateClientSecret();
|
||||||
this.savedParams.send_attempt = 1;
|
this.savedParams.send_attempt = 1;
|
||||||
cli.requestEmailToken(
|
cli.requestEmailToken(
|
||||||
this.savedParams.email,
|
this.savedParams.email,
|
||||||
@ -150,6 +155,7 @@ t
|
|||||||
onRegistered: function(user_id, access_token) {
|
onRegistered: function(user_id, access_token) {
|
||||||
MatrixClientPeg.replace(Matrix.createClient({
|
MatrixClientPeg.replace(Matrix.createClient({
|
||||||
baseUrl: this.state.hs_url,
|
baseUrl: this.state.hs_url,
|
||||||
|
idBaseUrl: this.state.is_url,
|
||||||
userId: user_id,
|
userId: user_id,
|
||||||
accessToken: access_token
|
accessToken: access_token
|
||||||
}));
|
}));
|
||||||
|
Loading…
Reference in New Issue
Block a user