diff --git a/src/deps.d.ts b/src/deps.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..6ecc3c0bd75eb7823e9bebc6c63274a81c0c655f --- /dev/null +++ b/src/deps.d.ts @@ -0,0 +1 @@ +declare module "hydrogen-view-sdk"; diff --git a/src/viewmodels/AccountSetupViewModel.ts b/src/viewmodels/AccountSetupViewModel.ts index 5791a7ddac89d3da12d463043a0d2f8cd1ff695f..098cb0d69e019ab90735dc546098056e92c5e10f 100644 --- a/src/viewmodels/AccountSetupViewModel.ts +++ b/src/viewmodels/AccountSetupViewModel.ts @@ -9,7 +9,6 @@ export class AccountSetupViewModel extends ViewModel { private _client: Client; private _state: ObservableValue<string>; private _termsStage?: any; - private _username: string; private _password: string; constructor(options) { @@ -21,9 +20,8 @@ export class AccountSetupViewModel extends ViewModel { } private async _startRegistration(): Promise<void> { - this._username = generateRandomString(7); this._password = generateRandomString(10); - let stage = await this._client.startRegistration(this._homeserver, this._username, this._password, "Chatterbox"); + let stage = await this._client.startRegistration(this._homeserver, null, this._password, "Chatterbox"); if (stage.type === "m.login.terms") { this._termsStage = stage; this.emitChange("termsStage"); @@ -32,10 +30,11 @@ export class AccountSetupViewModel extends ViewModel { async completeRegistration() { let stage = this._termsStage; - while (stage !== true) { + while (typeof stage !== "string") { stage = await stage.complete(); } - await this.login(this._username, this._password); + // stage is username when registration is completed + await this.login(stage, this._password); } async login(username: string, password: string): Promise<void> {