Get Recaptcha working again. Add a backchannel for stage prodding.
Recaptcha is a special snowflake because it dynamically loads the script and THEN renders with info from the registration request. This means we need a back-channel for the UI component to 'tell' the stage that everything is loaded. This Just Works which is nice.
This commit is contained in:
parent
991a96cfc5
commit
3e903be73d
2 changed files with 48 additions and 8 deletions
|
@ -38,8 +38,9 @@ class Register extends Signup {
|
|||
this.username = null; // desired
|
||||
this.email = null; // desired
|
||||
this.password = null; // desired
|
||||
this.params = {}; // random other stuff (e.g. query params)
|
||||
this.params = {}; // random other stuff (e.g. query params, NOT params from the server)
|
||||
this.credentials = null;
|
||||
this.activeStage = null;
|
||||
}
|
||||
|
||||
setClientSecret(secret) {
|
||||
|
@ -66,6 +67,10 @@ class Register extends Signup {
|
|||
return this.credentials;
|
||||
}
|
||||
|
||||
getServerData() {
|
||||
return this.data || {};
|
||||
}
|
||||
|
||||
setStep(step) {
|
||||
this._step = 'Register.' + step;
|
||||
// TODO:
|
||||
|
@ -112,6 +117,7 @@ class Register extends Signup {
|
|||
var flow = self.chooseFlow(error.data.flows);
|
||||
|
||||
if (flow) {
|
||||
console.log("Active flow => %s", JSON.stringify(flow));
|
||||
var flowStage = self.firstUncompletedStageIndex(flow);
|
||||
return self.startStage(flow.stages[flowStage]);
|
||||
}
|
||||
|
@ -174,6 +180,7 @@ class Register extends Signup {
|
|||
}
|
||||
|
||||
var stage = new StageClass(MatrixClientPeg.get(), this);
|
||||
this.activeStage = stage;
|
||||
return stage.complete().then(function(request) {
|
||||
if (request.auth) {
|
||||
return self._tryRegister(request.auth);
|
||||
|
@ -220,6 +227,13 @@ class Register extends Signup {
|
|||
return otherFlow;
|
||||
}
|
||||
}
|
||||
|
||||
tellStage(stageName, data) {
|
||||
if (this.activeStage && this.activeStage.type === stageName) {
|
||||
console.log("Telling stage %s about something..", stageName);
|
||||
this.activeStage.onReceiveData(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue