Merge pull request #741 from matrix-org/dbkr/fix_teamserver_2

Fix the team server registration
This commit is contained in:
David Baker 2017-03-06 17:57:42 +00:00 committed by GitHub
commit 65ce8c2113
2 changed files with 21 additions and 17 deletions

View file

@ -45,7 +45,14 @@ export default React.createClass({
// successfully or unsuccessfully. // successfully or unsuccessfully.
// @param {bool} status True if the operation requiring // @param {bool} status True if the operation requiring
// auth was completed sucessfully, false if canceled. // 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, onAuthFinished: React.PropTypes.func.isRequired,
// Inputs provided by the user to the auth process // Inputs provided by the user to the auth process
@ -88,7 +95,11 @@ export default React.createClass({
}); });
this._authLogic.attemptAuth().then((result) => { 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) => { }).catch((error) => {
this.props.onAuthFinished(false, error); this.props.onAuthFinished(false, error);
console.error("Error during user-interactive auth:", error); console.error("Error during user-interactive auth:", error);

View file

@ -153,7 +153,7 @@ module.exports = React.createClass({
}); });
}, },
_onUIAuthFinished: function(success, response) { _onUIAuthFinished: function(success, response, extra) {
if (!success) { if (!success) {
this.setState({ this.setState({
busy: false, busy: false,
@ -168,26 +168,19 @@ module.exports = React.createClass({
busy: true, busy: true,
doingUIAuth: false, 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 // 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 // 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 // that the user registered with at this stage (depending on whether this
// is the client they initiated registration). // is the client they initiated registration).
let trackPromise = q(null); 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 // Track referral if this.props.referrer set, get team_token in order to
// retrieve team config and see welcome page etc. // retrieve team config and see welcome page etc.
trackPromise = this._rtsClient.trackReferral( trackPromise = this._rtsClient.trackReferral(
this.props.referrer || '', // Default to empty string = not referred this.props.referrer || '', // Default to empty string = not referred
this.registerLogic.params.idSid, extra.emailSid,
this.registerLogic.params.clientSecret extra.clientSecret,
).then((data) => { ).then((data) => {
const teamToken = data.team_token; const teamToken = data.team_token;
// Store for use /w welcome pages // Store for use /w welcome pages
@ -223,13 +216,13 @@ module.exports = React.createClass({
this.props.onLoggedIn({ this.props.onLoggedIn({
userId: response.user_id, userId: response.user_id,
deviceId: response.device_id, deviceId: response.device_id,
homeserverUrl: this.registerLogic.getHomeserverUrl(), homeserverUrl: this._matrixClient.getHomeserverUrl(),
identityServerUrl: this.registerLogic.getIdentityServerUrl(), identityServerUrl: this._matrixClient.getIdentityServerUrl(),
accessToken: response.access_token accessToken: response.access_token
}, teamToken); }, teamToken);
}).then(() => { }).then(() => {
return this._setupPushers(); return this._setupPushers();
}).done(); });
}, },
_setupPushers: function() { _setupPushers: function() {
@ -316,7 +309,7 @@ module.exports = React.createClass({
); );
}, },
_getUIAuthInputs() { _getUIAuthInputs: function() {
return { return {
emailAddress: this.state.formVals.email, emailAddress: this.state.formVals.email,
phoneCountry: this.state.formVals.phoneCountry, phoneCountry: this.state.formVals.phoneCountry,