Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't login after registration #97

Merged
merged 3 commits into from
Oct 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"author": "matrix.org",
"license": "Apache-2.0",
"scripts": {
"start": "vite",
"start": "vite --port 5400",
"build": "tsc && vite build && vite build --config parent-vite.config.js && scripts/after-build.sh",
"preview": "vite preview"
},
Expand All @@ -19,6 +19,6 @@
"dependencies": {
"@sentry/browser": "^7.5.0",
"@sentry/tracing": "^7.5.0",
"hydrogen-view-sdk": "^0.1.0"
"hydrogen-view-sdk": "^0.1.1"
}
}
7 changes: 6 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,12 @@ async function main() {
}
}

const platform = new Platform({container: root, assetPaths, config: {}, options: { development: import.meta.env.DEV }});
const platform = new Platform({
container: root,
assetPaths,
config: { themeManifests: [] },
options: { development: import.meta.env.DEV },
});
attachLogExportToWindow(platform);
const navigation = new Navigation(allowsChild);
platform.setNavigation(navigation);
Expand Down
15 changes: 6 additions & 9 deletions src/viewmodels/AccountSetupViewModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ export class AccountSetupViewModel extends ViewModel {
private _config: IChatterboxConfig;
private _client: typeof Client;
private _startStage?: any;
private _password: string;
private _registration: any;
private _privacyPolicyLink: string;
private _showButtonSpinner: boolean = false;
Expand All @@ -37,7 +36,7 @@ export class AccountSetupViewModel extends ViewModel {
}

private async _startRegistration(): Promise<void> {
this._password = generatePassword(10);
const password = generatePassword(10);
const maxAttempts = 10;
for (let i = 0; i < maxAttempts; ++i) {
try {
Expand All @@ -59,7 +58,7 @@ export class AccountSetupViewModel extends ViewModel {
}
}
}
this._registration = await this._client.startRegistration(this._homeserver, username, this._password, "Chatterbox", flowSelector);
this._registration = await this._client.startRegistration(this._homeserver, username, password, "Chatterbox", flowSelector);
this._startStage = await this._registration.start();
let stage = this._startStage;
while (stage && stage.type !== "m.login.terms") {
Expand Down Expand Up @@ -95,14 +94,12 @@ export class AccountSetupViewModel extends ViewModel {
}
stage = await this._registration.submitStage(stage);
}
const loginPromise = this.login(this._password);
this.navigation.push("timeline", loginPromise);
const promise = this.setupSession();
this.navigation.push("timeline", promise);
}

async login(password: string): Promise<void> {
const loginOptions = await this._client.queryLogin(this._homeserver).result;
const username = this._registration.sessionInfo.user_id;
this._client.startWithLogin(loginOptions.password(username, password));
async setupSession(): Promise<void> {
this._client.startWithAuthData(this._registration.authData);
await this._client.loadStatus.waitFor((status: string) => {
return status === LoadStatus.Ready ||
status === LoadStatus.Error ||
Expand Down
2 changes: 1 addition & 1 deletion src/viewmodels/RootViewModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export class RootViewModel extends ViewModel {

private _setupNavigation() {
this.navigation.observe("account-setup").subscribe(() => this._showAccountSetup());
this.navigation.observe("timeline").subscribe((loginPromise) => this._showTimeline(loginPromise));
this.navigation.observe("timeline").subscribe((setupSessionPromise) => this._showTimeline(setupSessionPromise));
this.navigation.observe("minimize").subscribe(() => this.minimizeChatterbox());
}

Expand Down
22 changes: 11 additions & 11 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ aggregate-error@^3.0.0:
another-json@^0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/another-json/-/another-json-0.2.0.tgz#b5f4019c973b6dd5c6506a2d93469cb6d32aeedc"
integrity sha1-tfQBnJc7bdXGUGotk0acttMq7tw=
integrity sha512-/Ndrl68UQLhnCdsAzEXLMFuOR546o2qbYRqCglaNHbjXrwG1ayTcdwr3zkSGOGtGXDyR5X9nCFfnyG2AFJIsqg==

ansi-colors@^4.1.1:
version "4.1.3"
Expand Down Expand Up @@ -356,9 +356,9 @@ [email protected]:
integrity sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==

core-js@^3.6.5:
version "3.22.2"
resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.22.2.tgz#3ea0a245b0895fa39d1faa15fe75d91ade504a01"
integrity sha512-Z5I2vzDnEIqO2YhELVMFcL1An2CIsFe9Q7byZhs8c/QxummxZlAHw33TUHbIte987LkisOgL0LwQ1P9D6VISnA==
version "3.25.5"
resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.25.5.tgz#e86f651a2ca8a0237a5f064c2fe56cef89646e27"
integrity sha512-nbm6eZSjm+ZuBQxCUPQKQCoUEfFOXjUZ8dTTyikyKaWrTYmAVbykQfwsKE5dBK88u3QCkCrzsx/PPlKfhsvgpw==

[email protected]:
version "1.0.2"
Expand Down Expand Up @@ -459,9 +459,9 @@ delayed-stream@~1.0.0:
integrity sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==

dompurify@^2.3.0:
version "2.3.6"
resolved "https://registry.yarnpkg.com/dompurify/-/dompurify-2.3.6.tgz#2e019d7d7617aacac07cbbe3d88ae3ad354cf875"
integrity sha512-OFP2u/3T1R5CEgWCEONuJ1a5+MFKnOYpkywpUSxv/dj1LeBT1erK+JwM7zK0ROy2BRhqVCf0LRw/kHqKuMkVGg==
version "2.4.0"
resolved "https://registry.yarnpkg.com/dompurify/-/dompurify-2.4.0.tgz#c9c88390f024c2823332615c9e20a453cf3825dd"
integrity sha512-Be9tbQMZds4a3C6xTmz68NlMfeONA//4dOavl/1rNw50E+/QO0KVpbcU0PcaW0nsQxurXls9ZocqFxk8R2mWEA==

ecc-jsbn@~0.1.1:
version "0.1.2"
Expand Down Expand Up @@ -798,10 +798,10 @@ human-signals@^1.1.1:
resolved "https://registry.yarnpkg.com/human-signals/-/human-signals-1.1.1.tgz#c5b1cd14f50aeae09ab6c59fe63ba3395fe4dfa3"
integrity sha512-SEQu7vl8KjNL2eoGBLF3+wAjpsNfA9XMlXAYj/3EdaNfAlxKthD1xjEQfGOUhllCGGJVNY34bRr6lPINhNjyZw==

hydrogen-view-sdk@^0.1.0:
version "0.1.0"
resolved "https://registry.yarnpkg.com/hydrogen-view-sdk/-/hydrogen-view-sdk-0.1.0.tgz#564af3a14030a988d4870e036044824b1fcb33b7"
integrity sha512-BkQ7PdWxK/vZRsxsChjaByTUEp7FoB96Dya6fpldUv9OAVZE8kyW/z2Xh4chR1mMMf9SrjYLThXZQs+sHvWWFg==
hydrogen-view-sdk@^0.1.1:
version "0.1.1"
resolved "https://registry.yarnpkg.com/hydrogen-view-sdk/-/hydrogen-view-sdk-0.1.1.tgz#9b221bc63c48c1aec631ed6d5296643f6840c720"
integrity sha512-xSWLu1Y0JqP0RaFWoWJYa5VWPlz8TeBif6qk0U9RVFACzF/asYYq7Ti0J3JwhR6AZSpFONKCIuC6TuTUGRoN7g==
dependencies:
"@matrix-org/olm" "https://gitlab.matrix.org/api/v4/projects/27/packages/npm/@matrix-org/olm/-/@matrix-org/olm-3.2.8.tgz"
another-json "^0.2.0"
Expand Down