mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 03:25:12 +01:00
Pass in params to BaseRegistrationStage
This commit is contained in:
parent
a59b67ec45
commit
18e2fc1089
@ -34,7 +34,6 @@ export class Registration {
|
|||||||
private _hsApi: HomeServerApi;
|
private _hsApi: HomeServerApi;
|
||||||
private _data: RegistrationParameters;
|
private _data: RegistrationParameters;
|
||||||
private _firstStage: BaseRegistrationStage;
|
private _firstStage: BaseRegistrationStage;
|
||||||
private _session: string;
|
|
||||||
|
|
||||||
constructor(hsApi: HomeServerApi, data: RegistrationParameters) {
|
constructor(hsApi: HomeServerApi, data: RegistrationParameters) {
|
||||||
this._hsApi = hsApi;
|
this._hsApi = hsApi;
|
||||||
@ -58,7 +57,7 @@ export class Registration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
parseStagesFromResponse(response: RegistrationResponse) {
|
parseStagesFromResponse(response: RegistrationResponse) {
|
||||||
this._session = response.session;
|
const { session, params } = response;
|
||||||
const flow = response.flows.pop();
|
const flow = response.flows.pop();
|
||||||
let lastStage: BaseRegistrationStage;
|
let lastStage: BaseRegistrationStage;
|
||||||
for (const stage of flow.stages) {
|
for (const stage of flow.stages) {
|
||||||
@ -66,7 +65,7 @@ export class Registration {
|
|||||||
if (!stageClass) {
|
if (!stageClass) {
|
||||||
throw new Error("Unknown stage");
|
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) {
|
if (!this._firstStage) {
|
||||||
this._firstStage = registrationStage;
|
this._firstStage = registrationStage;
|
||||||
lastStage = registrationStage;
|
lastStage = registrationStage;
|
||||||
|
@ -26,11 +26,13 @@ export abstract class BaseRegistrationStage {
|
|||||||
protected _registrationData: RegistrationParameters;
|
protected _registrationData: RegistrationParameters;
|
||||||
protected _session: string;
|
protected _session: string;
|
||||||
protected _nextStage: BaseRegistrationStage;
|
protected _nextStage: BaseRegistrationStage;
|
||||||
|
protected _params?: Record<string, any>
|
||||||
|
|
||||||
constructor(hsApi: HomeServerApi, registrationData: RegistrationParameters, session: string) {
|
constructor(hsApi: HomeServerApi, registrationData: RegistrationParameters, session: string, params?: Record<string, any>) {
|
||||||
this._hsApi = hsApi;
|
this._hsApi = hsApi;
|
||||||
this._registrationData = registrationData;
|
this._registrationData = registrationData;
|
||||||
this._session = session;
|
this._session = session;
|
||||||
|
this._params = params;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user