-
-
Notifications
You must be signed in to change notification settings - Fork 833
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 @@ | |||
/* |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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?)
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
(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, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
now redundant
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isRequired
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add matrixClient
to propTypes
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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} |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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) => { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
as Registration was still using it
ptal |
} | ||
}); | ||
}, (err) => { | ||
console.error('Error getting team config', err); | ||
}); | ||
|
||
return teamToken; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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.
There was a problem hiding this 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
when auth fails
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
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