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; } /**