Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/components/structures/InteractiveAuth.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ export default React.createClass({
clientSecret: React.PropTypes.string,
emailSid: React.PropTypes.string,

// Callback to be run with the auth object, when it
// has been created. This allows the component to
// access more specific functions only available on
// the auth object itself.
onAuthObject: React.PropTypes.func,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is surely horrible. why not pass an opts object into the onAuthFinished callback with the emailSid and clientSecret?


// If true, poll to see if the auth flow has been completed
// out-of-band
poll: React.PropTypes.bool,
Expand Down Expand Up @@ -86,6 +92,7 @@ export default React.createClass({
clientSecret: this.props.clientSecret,
emailSid: this.props.emailSid,
});
if (this.props.onAuthObject) this.props.onAuthObject(this._authLogic);

this._authLogic.attemptAuth().then((result) => {
this.props.onAuthFinished(true, result);
Expand Down
27 changes: 13 additions & 14 deletions src/components/structures/login/Registration.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ module.exports = React.createClass({

componentWillMount: function() {
this._unmounted = false;
this._authLogic = null;

this._replaceClient();

Expand Down Expand Up @@ -168,26 +169,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);
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was the same thing as was done after the trackPromise: we should just do it then.

if (this._rtsClient) {
if (this._rtsClient && this._authLogic.getEmailSid()) {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The referral tracking only makes sense if we registered with an email

// 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
this._authLogic.getEmailSid(),
this._authLogic.getClientSecret(),
).then((data) => {
const teamToken = data.team_token;
// Store for use /w welcome pages
Expand Down Expand Up @@ -223,13 +217,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() {
Expand Down Expand Up @@ -316,14 +310,18 @@ module.exports = React.createClass({
);
},

_getUIAuthInputs() {
_getUIAuthInputs: function() {
return {
emailAddress: this.state.formVals.email,
phoneCountry: this.state.formVals.phoneCountry,
phoneNumber: this.state.formVals.phoneNumber,
}
},

_onAuthObject: function(authLogic) {
this._authLogic = authLogic;
},

render: function() {
const LoginHeader = sdk.getComponent('login.LoginHeader');
const LoginFooter = sdk.getComponent('login.LoginFooter');
Expand All @@ -343,6 +341,7 @@ module.exports = React.createClass({
sessionId={this.props.sessionId}
clientSecret={this.props.clientSecret}
emailSid={this.props.idSid}
onAuthObject={this._onAuthObject}
poll={true}
/>
);
Expand Down