Port registration over to use InteractiveAuth - #729
Conversation
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
as commented
| @@ -0,0 +1,177 @@ | |||
| /* | |||
| this._authLogic.attemptAuth().then((result) => { | ||
| this.props.onFinished(true, result); | ||
| }).catch((error) => { | ||
| this.props.onFinished(false, error); |
There was a problem hiding this comment.
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?)
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Yes, I think so. It might also be worth renaming the onFinished property here to distinguish it from the one used in dialogs.
(This ended up mostly being merged by hand as git made a complete mess of the merge)
| @@ -61,11 +79,18 @@ export default React.createClass({ | |||
| authData: this.props.authData, | |||
| doRequest: this._requestCallback, | |||
| startAuthStage: this._startAuthStage, | |||
| }, | ||
|
|
||
| propTypes: { | ||
| matrixClient: React.PropTypes.object, |
| }, | ||
|
|
||
| propTypes: { | ||
| matrixClient: React.PropTypes.object, |
|
|
||
| _onShowFallbackClick: function() { | ||
| var url = MatrixClientPeg.get().getFallbackAuthUrl( | ||
| var url = this.props.matrixClient.getFallbackAuthUrl( |
| // 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(); |
There was a problem hiding this comment.
do we need to resume it if the user cancels registration? or does that happen anyway?
There was a problem hiding this comment.
It's already done (have commented)
| if (this.props.startingFragmentQueryParams.referrer) { | ||
| params.referrer = this.props.startingFragmentQueryParams.referrer; | ||
| } | ||
| return this.props.makeRegistrationUrl(params); |
There was a problem hiding this comment.
can you add makeRegistrationUrl to propTypes pls
| sessionId={this.state.register_session_id} | ||
| idSid={this.state.register_id_sid} | ||
| email={this.props.startingFragmentQueryParams.email} | ||
| referrer={this.props.startingFragmentQueryParams.referrer} |
There was a problem hiding this comment.
need to remove referrer from Registration.propTypes
There was a problem hiding this comment.
Actually, Registration was still using this: I've re-added it
There was a problem hiding this comment.
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
| clientSecret: React.PropTypes.string, | ||
| sessionId: React.PropTypes.string, | ||
| registrationUrl: React.PropTypes.string, | ||
| makeRegistrationUrl: React.PropTypes.func, |
| @@ -42,7 +42,7 @@ module.exports = React.createClass({ | |||
| onLoggedIn: React.PropTypes.func.isRequired, | |||
There was a problem hiding this comment.
there's a TODO at line 35 which can go
| }); | ||
| } | ||
|
|
||
| trackPromise.then((teamToken) => { |
There was a problem hiding this comment.
what's trackPromise here? you seem to have vaped the code that set it?
There was a problem hiding this comment.
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.
as Registration was still using it
|
ptal |
| console.error('Error getting team config', err); | ||
| }); | ||
|
|
||
| return teamToken; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
Looks like this still needs attention.
when auth fails
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