Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Port registration over to use InteractiveAuth #729

Merged
merged 21 commits into from
Mar 3, 2017
Merged

Conversation

dbkr
Copy link
Member

@dbkr dbkr commented Feb 27, 2017

These changes are moved over from the dbkr/msisdn_signin branch

Also fixes a couple of bugs:

Requires matrix-org/matrix-js-sdk#380 (hence failing tests)
Requires element-hq/element-web#3333

These changes are moved over from the dbkr/msisdn_signin branch
on registration (both for email validation and completion of the
whole auth session).
 * Also fix bug where you couldn't picxk a different server if
   you were already registered as a guest (because it still sent
   the access token which the new server rejected)
 * Propagate errors from UI auth back to registration so it goes
   back to the registration screen
@@ -0,0 +1,177 @@
/*
Copy link
Member Author

Choose a reason for hiding this comment

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

Moved from Signup.js

});

this._authLogic.attemptAuth().then((result) => {
this.props.onFinished(true, result);
}).catch((error) => {
this.props.onFinished(false, error);
Copy link
Member

Choose a reason for hiding this comment

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

in an InteractiveAuthDialog, this will close the dialog and swallow the error. Admittedly the current handling of non-interactive-auth errors seems to be totally broken, but this also seems wrong.

(I'm sure I tested non-interactive-auth errors. Perhaps it got broken when matthew added the auth cache stuff?)

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm, yeah. Seems like the issue is that while the non-dialog version wants the InteractiveAuth to go away, since there's no value in the thing sitting there saying 'error'. This isn't sensible for the dialog version though, and you do want the dialog to say it failed, then you can close it & try again.

So seems like the right fix is to make the dialog version catch onFinished(false) and replace the InteractiveAuth component with an error message?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, I think so. It might also be worth renaming the onFinished property here to distinguish it from the one used in dialogs.

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@@ -61,11 +79,18 @@ export default React.createClass({
authData: this.props.authData,
doRequest: this._requestCallback,
startAuthStage: this._startAuthStage,
Copy link
Member

Choose a reason for hiding this comment

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

now redundant

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

},

propTypes: {
matrixClient: React.PropTypes.object,
Copy link
Member

Choose a reason for hiding this comment

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

isRequired

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@@ -48,6 +66,7 @@ export const PasswordAuthEntry = React.createClass({
},

propTypes: {
matrixClient: React.PropTypes.object,
Copy link
Member

Choose a reason for hiding this comment

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

isRequired

@@ -189,7 +280,7 @@ export const FallbackAuthEntry = React.createClass({
},

_onShowFallbackClick: function() {
var url = MatrixClientPeg.get().getFallbackAuthUrl(
var url = this.props.matrixClient.getFallbackAuthUrl(
Copy link
Member

Choose a reason for hiding this comment

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

add matrixClient to propTypes

Copy link
Member Author

Choose a reason for hiding this comment

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

done

// stop the client: if we are syncing whilst the registration
// is completed in another browser, we'll be 401ed for using
// a guest access token for a non-guest account.
Lifecycle.stopMatrixClient();
Copy link
Member

Choose a reason for hiding this comment

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

do we need to resume it if the user cancels registration? or does that happen anyway?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's already done (have commented)

if (this.props.startingFragmentQueryParams.referrer) {
params.referrer = this.props.startingFragmentQueryParams.referrer;
}
return this.props.makeRegistrationUrl(params);
Copy link
Member

Choose a reason for hiding this comment

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

can you add makeRegistrationUrl to propTypes pls

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@@ -1120,7 +1132,6 @@ module.exports = React.createClass({
sessionId={this.state.register_session_id}
idSid={this.state.register_id_sid}
email={this.props.startingFragmentQueryParams.email}
referrer={this.props.startingFragmentQueryParams.referrer}
Copy link
Member

Choose a reason for hiding this comment

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

need to remove referrer from Registration.propTypes

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually, Registration was still using this: I've re-added it

Copy link
Member

Choose a reason for hiding this comment

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

ick. I wonder if the _makeRegistrationUrl wrapper to add the referrer belongs in Registration then. I'm bored of this PR though, let's just get it shipped

@@ -42,7 +42,7 @@ module.exports = React.createClass({
onLoggedIn: React.PropTypes.func.isRequired,
clientSecret: React.PropTypes.string,
sessionId: React.PropTypes.string,
registrationUrl: React.PropTypes.string,
makeRegistrationUrl: React.PropTypes.func,
Copy link
Member

Choose a reason for hiding this comment

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

isRequired, I think?

@@ -42,7 +42,7 @@ module.exports = React.createClass({
onLoggedIn: React.PropTypes.func.isRequired,
Copy link
Member

Choose a reason for hiding this comment

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

there's a TODO at line 35 which can go

Copy link
Member Author

Choose a reason for hiding this comment

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

done, yay!

});
}

trackPromise.then((teamToken) => {
Copy link
Member

Choose a reason for hiding this comment

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

what's trackPromise here? you seem to have vaped the code that set it?

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks - yeah, this was git making a mess of merging in luke's PR, and this must have been something I lost in trying to fix the merge.

@richvdh richvdh assigned dbkr and unassigned richvdh Mar 2, 2017
@dbkr
Copy link
Member Author

dbkr commented Mar 2, 2017

ptal

@dbkr dbkr assigned richvdh and unassigned dbkr Mar 2, 2017
}
});
}, (err) => {
console.error('Error getting team config', err);
});

return teamToken;
Copy link
Member

Choose a reason for hiding this comment

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

Now that I've got github to give me a sensible diff, I can see you've moved this inside the getTeam.then callback - previously teamToken would be returned even if the getTeam call failed. Was that deliberate? I suspect it will be fine, but thought I'd check.

Copy link
Member Author

Choose a reason for hiding this comment

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

Well spotted, no that wasn't deliberate, unsure it matters a great deal but have put it back.

to when teamToken was returned
});

this._authLogic.attemptAuth().then((result) => {
this.props.onFinished(true, result);
}).catch((error) => {
this.props.onFinished(false, error);
Copy link
Member

Choose a reason for hiding this comment

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

Looks like this still needs attention.

Copy link
Member

@richvdh richvdh left a comment

Choose a reason for hiding this comment

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

just the onFinished thing

@richvdh richvdh assigned dbkr and unassigned richvdh Mar 3, 2017
@dbkr dbkr assigned richvdh and unassigned dbkr Mar 3, 2017
Copy link
Member

@richvdh richvdh left a comment

Choose a reason for hiding this comment

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

lgtm

@richvdh richvdh assigned dbkr and unassigned richvdh Mar 3, 2017
@dbkr dbkr merged commit 1bdf213 into develop Mar 3, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants