From 7568a3b2d346236447206271795484095de28e9f Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Thu, 19 Nov 2015 14:16:49 +0000 Subject: [PATCH] Hookup 2nd stage email registration; not finished as we aren't storing u/p --- src/Signup.js | 23 +++++++++++++++++++++++ src/SignupStages.js | 29 +++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/src/Signup.js b/src/Signup.js index db69441d6f..7e3b3335ff 100644 --- a/src/Signup.js +++ b/src/Signup.js @@ -234,6 +234,29 @@ class Register extends Signup { } } + recheckState() { + // feels a bit wrong to be clobbering the global client for something we + // don't even know if it'll work, but we'll leave this here for now to + // not complicate matters further. It would be nicer to isolate this + // logic entirely from the rest of the app though. + MatrixClientPeg.replaceUsingUrls( + this._hsUrl, + this._isUrl + ); + // We've been given a bunch of data from a previous register step, + // this only happens for email auth currently. It's kinda ming we need + // to know this though. A better solution would be to ask the stages if + // they are ready to do something rather than accepting that we know about + // email auth and its internals. + this.params.hasEmailInfo = ( + this.params.clientSecret && this.params.sessionId && this.params.idSid + ); + + if (this.params.hasEmailInfo) { + this.startStage(EMAIL_STAGE_TYPE); + } + } + tellStage(stageName, data) { if (this.activeStage && this.activeStage.type === stageName) { console.log("Telling stage %s about something..", stageName); diff --git a/src/SignupStages.js b/src/SignupStages.js index d49a488ec8..53e75e39ea 100644 --- a/src/SignupStages.js +++ b/src/SignupStages.js @@ -105,7 +105,36 @@ class EmailIdentityStage extends Stage { super(EmailIdentityStage.TYPE, matrixClient, signupInstance); } + _completeVerify() { + console.log("_completeVerify"); + var isLocation = document.createElement('a'); + isLocation.href = this.signupInstance.getIdentityServerUrl(); + + return q({ + auth: { + type: 'm.login.email.identity', + threepid_creds: { + sid: this.signupInstance.params.idSid, + client_secret: this.signupInstance.params.clientSecret, + id_server: isLocation.host + } + } + }); + } + + /** + * Complete the email stage. + * + * This is called twice under different circumstances: + * 1) When requesting an email token from the IS + * 2) When validating query parameters received from the link in the email + */ complete() { + console.log("Email complete()"); + if (this.signupInstance.params.hasEmailInfo) { + return this._completeVerify(); + } + var config = { clientSecret: this.client.generateClientSecret(), sendAttempt: 1