From 18e2fc108928f514ca8ff2c4db4abbcda16fc48d Mon Sep 17 00:00:00 2001 From: RMidhunSuresh Date: Mon, 27 Dec 2021 12:54:54 +0530 Subject: [PATCH] Pass in params to BaseRegistrationStage --- src/matrix/registration/Registration.ts | 5 ++--- src/matrix/registration/stages/BaseRegistrationStage.ts | 4 +++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/matrix/registration/Registration.ts b/src/matrix/registration/Registration.ts index 1432f41a..312c442b 100644 --- a/src/matrix/registration/Registration.ts +++ b/src/matrix/registration/Registration.ts @@ -34,7 +34,6 @@ export class Registration { private _hsApi: HomeServerApi; private _data: RegistrationParameters; private _firstStage: BaseRegistrationStage; - private _session: string; constructor(hsApi: HomeServerApi, data: RegistrationParameters) { this._hsApi = hsApi; @@ -58,7 +57,7 @@ export class Registration { } parseStagesFromResponse(response: RegistrationResponse) { - this._session = response.session; + const { session, params } = response; const flow = response.flows.pop(); let lastStage: BaseRegistrationStage; for (const stage of flow.stages) { @@ -66,7 +65,7 @@ export class Registration { if (!stageClass) { throw new Error("Unknown stage"); } - const registrationStage = new stageClass(this._hsApi, this._data, this._session); + const registrationStage = new stageClass(this._hsApi, this._data, session, params?.[stage]); if (!this._firstStage) { this._firstStage = registrationStage; lastStage = registrationStage; diff --git a/src/matrix/registration/stages/BaseRegistrationStage.ts b/src/matrix/registration/stages/BaseRegistrationStage.ts index 51115974..1458c554 100644 --- a/src/matrix/registration/stages/BaseRegistrationStage.ts +++ b/src/matrix/registration/stages/BaseRegistrationStage.ts @@ -26,11 +26,13 @@ export abstract class BaseRegistrationStage { protected _registrationData: RegistrationParameters; protected _session: string; protected _nextStage: BaseRegistrationStage; + protected _params?: Record - constructor(hsApi: HomeServerApi, registrationData: RegistrationParameters, session: string) { + constructor(hsApi: HomeServerApi, registrationData: RegistrationParameters, session: string, params?: Record) { this._hsApi = hsApi; this._registrationData = registrationData; this._session = session; + this._params = params; } /**