Skip to content
Snippets Groups Projects
Unverified Commit 3599f15c authored by R Midhun Suresh's avatar R Midhun Suresh Committed by GitHub
Browse files

Merge pull request #33 from vector-im/fix-28

Select first flow that contains no unsupported stage during registration
parents f15d68f2 2de21b34
No related branches found
No related tags found
No related merge requests found
...@@ -11,6 +11,6 @@ ...@@ -11,6 +11,6 @@
"vite": "^2.7.2" "vite": "^2.7.2"
}, },
"dependencies": { "dependencies": {
"hydrogen-view-sdk": "^0.0.10" "hydrogen-view-sdk": "^0.0.11"
} }
} }
...@@ -36,7 +36,7 @@ async function main() { ...@@ -36,7 +36,7 @@ async function main() {
} }
root.className = "hydrogen"; root.className = "hydrogen";
const config = await fetchConfig(); const config = await fetchConfig();
const platform = new Platform(root, assetPaths, {}, { development: import.meta.env.DEV }); const platform = new Platform({container: root, assetPaths, config: {}, options: { development: import.meta.env.DEV }});
const navigation = new Navigation(allowsChild); const navigation = new Navigation(allowsChild);
platform.setNavigation(navigation); platform.setNavigation(navigation);
const urlRouter = createRouter({ navigation, history: platform.history }); const urlRouter = createRouter({ navigation, history: platform.history });
......
...@@ -25,7 +25,24 @@ export class AccountSetupViewModel extends ViewModel { ...@@ -25,7 +25,24 @@ export class AccountSetupViewModel extends ViewModel {
for (let i = 0; i < maxAttempts; ++i) { for (let i = 0; i < maxAttempts; ++i) {
try { try {
const username = `${this._config.username_prefix}-${generateUsername(10)}`; const username = `${this._config.username_prefix}-${generateUsername(10)}`;
this._registration = await this._client.startRegistration(this._homeserver, username, this._password, "Chatterbox"); const flowSelector = (flows) => {
const allowedStages = [
"m.login.registration_token",
"org.matrix.msc3231.login.registration_token",
"m.login.terms",
"m.login.dummy"
];
for (const flow of flows) {
// Find the first flow that does not contain any unsupported stages but contains Token registration stage.
const containsUnsupportedStage = flow.stages.some(stage => !allowedStages.includes(stage));
const containsTokenStage = flow.stages.includes("m.login.registration_token") ||
flow.stages.includes("org.matrix.msc3231.login.registration_token");
if (!containsUnsupportedStage && containsTokenStage) {
return flow;
}
}
}
this._registration = await this._client.startRegistration(this._homeserver, username, this._password, "Chatterbox", flowSelector);
this._startStage = await this._registration.start(); this._startStage = await this._registration.start();
let stage = this._startStage; let stage = this._startStage;
while (stage && stage.type !== "m.login.terms") { while (stage && stage.type !== "m.login.terms") {
......
...@@ -163,10 +163,10 @@ has@^1.0.3: ...@@ -163,10 +163,10 @@ has@^1.0.3:
dependencies: dependencies:
function-bind "^1.1.1" function-bind "^1.1.1"
hydrogen-view-sdk@^0.0.10: hydrogen-view-sdk@^0.0.11:
version "0.0.10" version "0.0.11"
resolved "https://registry.yarnpkg.com/hydrogen-view-sdk/-/hydrogen-view-sdk-0.0.10.tgz#be0c729db67e1d1511b7fa32aa101fd889ec9cdc" resolved "https://registry.yarnpkg.com/hydrogen-view-sdk/-/hydrogen-view-sdk-0.0.11.tgz#01c224b6bfd2f89d98d2f9e1816cd962411b9982"
integrity sha512-7Ni7ui0mQzKbz6noGDyS1ceIKjU5sjoyX6+2a5dk0nXwttrQYXJbrgblCWC3nIljQPbW+09o+t9BFE0OuBHDPw== integrity sha512-a7z9FEa078MNuSAtNhoJ82ircGTGVvHnRsl+BvDQaHvgVb01/ff2r81KdIqdqVwXzC9r2McqjTNPCwEKh2Xauw==
dependencies: dependencies:
"@matrix-org/olm" "https://gitlab.matrix.org/api/v4/projects/27/packages/npm/@matrix-org/olm/-/@matrix-org/olm-3.2.3.tgz" "@matrix-org/olm" "https://gitlab.matrix.org/api/v4/projects/27/packages/npm/@matrix-org/olm/-/@matrix-org/olm-3.2.3.tgz"
another-json "^0.2.0" another-json "^0.2.0"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment