mirror of
https://github.com/element-hq/element-web.git
synced 2024-11-30 23:31:28 +03:00
Merge pull request #741 from matrix-org/dbkr/fix_teamserver_2
Fix the team server registration
This commit is contained in:
commit
65ce8c2113
2 changed files with 21 additions and 17 deletions
|
@ -45,7 +45,14 @@ export default React.createClass({
|
|||
// successfully or unsuccessfully.
|
||||
// @param {bool} status True if the operation requiring
|
||||
// auth was completed sucessfully, false if canceled.
|
||||
// @param result The result of the authenticated call
|
||||
// @param {object} result The result of the authenticated call
|
||||
// if successful, otherwise the error object
|
||||
// @param {object} extra Additional information about the UI Auth
|
||||
// process:
|
||||
// * emailSid {string} If email auth was performed, the sid of
|
||||
// the auth session.
|
||||
// * clientSecret {string} The client secret used in auth
|
||||
// sessions with the ID server.
|
||||
onAuthFinished: React.PropTypes.func.isRequired,
|
||||
|
||||
// Inputs provided by the user to the auth process
|
||||
|
@ -88,7 +95,11 @@ export default React.createClass({
|
|||
});
|
||||
|
||||
this._authLogic.attemptAuth().then((result) => {
|
||||
this.props.onAuthFinished(true, result);
|
||||
const extra = {
|
||||
emailSid: this._authLogic.getEmailSid(),
|
||||
clientSecret: this._authLogic.getClientSecret(),
|
||||
};
|
||||
this.props.onAuthFinished(true, result, extra);
|
||||
}).catch((error) => {
|
||||
this.props.onAuthFinished(false, error);
|
||||
console.error("Error during user-interactive auth:", error);
|
||||
|
|
|
@ -153,7 +153,7 @@ module.exports = React.createClass({
|
|||
});
|
||||
},
|
||||
|
||||
_onUIAuthFinished: function(success, response) {
|
||||
_onUIAuthFinished: function(success, response, extra) {
|
||||
if (!success) {
|
||||
this.setState({
|
||||
busy: false,
|
||||
|
@ -168,26 +168,19 @@ module.exports = React.createClass({
|
|||
busy: true,
|
||||
doingUIAuth: false,
|
||||
});
|
||||
this.props.onLoggedIn({
|
||||
userId: response.user_id,
|
||||
deviceId: response.device_id,
|
||||
homeserverUrl: this.state.hsUrl,
|
||||
identityServerUrl: this.state.isUrl,
|
||||
accessToken: response.access_token,
|
||||
});
|
||||
|
||||
// Done regardless of `teamSelected`. People registering with non-team emails
|
||||
// will just nop. The point of this being we might not have the email address
|
||||
// that the user registered with at this stage (depending on whether this
|
||||
// is the client they initiated registration).
|
||||
let trackPromise = q(null);
|
||||
if (this._rtsClient) {
|
||||
if (this._rtsClient && extra.emailSid) {
|
||||
// Track referral if this.props.referrer set, get team_token in order to
|
||||
// retrieve team config and see welcome page etc.
|
||||
trackPromise = this._rtsClient.trackReferral(
|
||||
this.props.referrer || '', // Default to empty string = not referred
|
||||
this.registerLogic.params.idSid,
|
||||
this.registerLogic.params.clientSecret
|
||||
extra.emailSid,
|
||||
extra.clientSecret,
|
||||
).then((data) => {
|
||||
const teamToken = data.team_token;
|
||||
// Store for use /w welcome pages
|
||||
|
@ -223,13 +216,13 @@ module.exports = React.createClass({
|
|||
this.props.onLoggedIn({
|
||||
userId: response.user_id,
|
||||
deviceId: response.device_id,
|
||||
homeserverUrl: this.registerLogic.getHomeserverUrl(),
|
||||
identityServerUrl: this.registerLogic.getIdentityServerUrl(),
|
||||
homeserverUrl: this._matrixClient.getHomeserverUrl(),
|
||||
identityServerUrl: this._matrixClient.getIdentityServerUrl(),
|
||||
accessToken: response.access_token
|
||||
}, teamToken);
|
||||
}).then(() => {
|
||||
return this._setupPushers();
|
||||
}).done();
|
||||
});
|
||||
},
|
||||
|
||||
_setupPushers: function() {
|
||||
|
@ -316,7 +309,7 @@ module.exports = React.createClass({
|
|||
);
|
||||
},
|
||||
|
||||
_getUIAuthInputs() {
|
||||
_getUIAuthInputs: function() {
|
||||
return {
|
||||
emailAddress: this.state.formVals.email,
|
||||
phoneCountry: this.state.formVals.phoneCountry,
|
||||
|
|
Loading…
Reference in a new issue