From 991104d15666011739abcc4fca6b36e3dc154571 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Wed, 28 Nov 2018 00:33:20 +0000 Subject: [PATCH] Handle well-known data in the login response ... as per [MSC1730](https://github.com/matrix-org/matrix-doc/pull/1730). --- src/Login.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/Login.js b/src/Login.js index 330eb8a8f5..ca045e36cd 100644 --- a/src/Login.js +++ b/src/Login.js @@ -204,6 +204,19 @@ export async function sendLoginRequest(hsUrl, isUrl, loginType, loginParams) { const data = await client.login(loginType, loginParams); + const wellknown = data.well_known; + if (wellknown) { + if (wellknown["m.homeserver"] && wellknown["m.homeserver"]["base_url"]) { + hsUrl = wellknown["m.homeserver"]["base_url"]; + console.log(`Overrode homeserver setting with ${hsUrl} from login response`); + } + if (wellknown["m.identity_server"] && wellknown["m.identity_server"]["base_url"]) { + // TODO: should we prompt here? + isUrl = wellknown["m.identity_server"]["base_url"]; + console.log(`Overrode IS setting with ${isUrl} from login response`); + } + } + return { homeserverUrl: hsUrl, identityServerUrl: isUrl,