diff --git a/README.md b/README.md index cf86f37fe7..dba59fd74a 100644 --- a/README.md +++ b/README.md @@ -113,10 +113,10 @@ For a good example, see https://riot.im/develop/config.json. Riot to use. The object is the same as returned by [https:///.well-known/matrix/client](https://matrix.org/docs/spec/client_server/latest.html#get-well-known-matrix-client), with added support for a `server_name` under the `m.homeserver` section to display a custom homeserver name. Alternatively, the config can contain a `default_server_name` - instead which is where Riot will go to get that same object - see the `.well-known` - link above for more information. Note that the `default_server_name` is used to get - a complete server configuration whereas the `server_name` in the `default_server_config` - is for display purposes only. + instead which is where Riot will go to get that same object, although this option is + deprecated - see the `.well-known` link above for more information on using this option. + Note that the `default_server_name` is used to get a complete server configuration + whereas the `server_name` in the `default_server_config` is for display purposes only. * *Note*: The URLs can also be individually specified as `default_hs_url` and `default_is_url`, however these are deprecated. They are maintained for backwards compatibility with older configurations. `default_is_url` is respected only diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 7f09a09f2f..2718b8e476 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -1,6 +1,6 @@ { "Unexpected error preparing the app. See console for details.": "Unexpected error preparing the app. See console for details.", - "This installation of Riot seems to have an invalid server configuration. If you are the administrator, please correct the error below": "This installation of Riot seems to have an invalid server configuration. If you are the administrator, please correct the error below", + "Your Riot is misconfigured": "Your Riot is misconfigured", "Invalid configuration: can only specify one of default_server_config, default_server_name, or default_hs_url.": "Invalid configuration: can only specify one of default_server_config, default_server_name, or default_hs_url.", "Invalid configuration: no default server specified.": "Invalid configuration: no default server specified.", "Riot Desktop on %(platformName)s": "Riot Desktop on %(platformName)s", diff --git a/src/vector/index.js b/src/vector/index.js index ad4902670c..597b3f374f 100644 --- a/src/vector/index.js +++ b/src/vector/index.js @@ -368,20 +368,12 @@ async function loadApp() { let errorMessage = err.translatedMessage || _t("Unexpected error preparing the app. See console for details."); - errorMessage = - {_t( - "This installation of Riot seems to have an invalid server configuration. " + - "If you are the administrator, please correct the error below", - )} -
-
- {errorMessage} -
; + errorMessage = {errorMessage}; // Like the compatibility page, AWOOOOOGA at the user const GenericErrorPage = sdk.getComponent("structures.GenericErrorPage"); window.matrixChat = ReactDOM.render( - , + , document.getElementById('matrixchat'), ); }); @@ -465,6 +457,11 @@ async function verifyServerConfig() { // context of email validation. Because we don't respect them otherwise, we do not need // to parse or consider them here. + // Note: Although we throw all 3 possible configuration options through a .well-known-style + // verification, we do not care if the servers are online at this point. We do moderately + // care if they are syntactically correct though, so we shove them through the .well-known + // validators for that purpose. + const config = SdkConfig.get(); let wkConfig = config['default_server_config']; // overwritten later under some conditions const serverName = config['default_server_name']; @@ -486,6 +483,10 @@ async function verifyServerConfig() { if (hsUrl) { console.log("Config uses a default_hs_url - constructing a default_server_config using this information"); + console.warn( + "DEPRECATED CONFIG OPTION: In the future, default_hs_url will not be accepted. Please use " + + "default_server_config instead.", + ); wkConfig = { "m.homeserver": { @@ -507,10 +508,14 @@ async function verifyServerConfig() { if (serverName) { console.log("Config uses a default_server_name - doing .well-known lookup"); + console.warn( + "DEPRECATED CONFIG OPTION: In the future, default_server_name will not be accepted. Please " + + "use default_server_config instead.", + ); discoveryResult = await AutoDiscovery.findClientConfig(serverName); } - validatedConfig = AutoDiscoveryUtils.buildValidatedConfigFromDiscovery(serverName, discoveryResult); + validatedConfig = AutoDiscoveryUtils.buildValidatedConfigFromDiscovery(serverName, discoveryResult, true); } catch (e) { const {hsUrl, isUrl, userId} = Lifecycle.getLocalStorageSessionVars(); if (hsUrl && userId) { @@ -518,7 +523,7 @@ async function verifyServerConfig() { console.warn("A session was found - suppressing config error and using the session's homeserver"); console.log("Using pre-existing hsUrl and isUrl: ", {hsUrl, isUrl}); - validatedConfig = await AutoDiscoveryUtils.validateServerConfigWithStaticUrls(hsUrl, isUrl); + validatedConfig = await AutoDiscoveryUtils.validateServerConfigWithStaticUrls(hsUrl, isUrl, true); } else { // the user is not logged in, so scream throw e; diff --git a/test/app-tests/loading.js b/test/app-tests/loading.js index 8e7a7807e8..0450d9fc05 100644 --- a/test/app-tests/loading.js +++ b/test/app-tests/loading.js @@ -240,6 +240,10 @@ describe('loading:', function() { uriFragment: "#/room/!room:id", }); + // Pass the liveliness checks + httpBackend.when("GET", "/versions").respond(200, {versions: ["r0.4.0"]}); + httpBackend.when("GET", "/api/v1").respond(200, {}); + Promise.delay(1).then(() => { // at this point, we're trying to do a guest registration; // we expect a spinner @@ -277,6 +281,10 @@ describe('loading:', function() { uriFragment: "#/login", }); + // Pass the liveliness checks + httpBackend.when("GET", "/versions").respond(200, {versions: ["r0.4.0"]}); + httpBackend.when("GET", "/api/v1").respond(200, {}); + return awaitLoginComponent(matrixChat).then(() => { // we expect a single component ReactTestUtils.findRenderedComponentWithType( @@ -285,8 +293,13 @@ describe('loading:', function() { // the only outstanding request should be a GET /login // (in particular there should be no /register request for // guest registration). + const allowedRequests = [ + "/_matrix/client/r0/login", + "/versions", + "/api/v1", + ]; for (const req of httpBackend.requests) { - if (req.method === 'GET' && req.path.endsWith('/_matrix/client/r0/login')) { + if (req.method === 'GET' && allowedRequests.find(p => req.path.endsWith(p))) { continue; } @@ -387,6 +400,10 @@ describe('loading:', function() { }); it('shows a login view', function() { + // Pass the liveliness checks + httpBackend.when("GET", "/versions").respond(200, {versions: ["r0.4.0"]}); + httpBackend.when("GET", "/api/v1").respond(200, {}); + // we expect a single component ReactTestUtils.findRenderedComponentWithType( matrixChat, sdk.getComponent('structures.auth.Login'), @@ -395,8 +412,13 @@ describe('loading:', function() { // the only outstanding request should be a GET /login // (in particular there should be no /register request for // guest registration, nor /sync, etc). + const allowedRequests = [ + "/_matrix/client/r0/login", + "/versions", + "/api/v1", + ]; for (const req of httpBackend.requests) { - if (req.method === 'GET' && req.path.endsWith('/_matrix/client/r0/login')) { + if (req.method === 'GET' && allowedRequests.find(p => req.path.endsWith(p))) { continue; } @@ -405,6 +427,10 @@ describe('loading:', function() { }); it('shows the homepage after login', function() { + // Pass the liveliness checks + httpBackend.when("GET", "/versions").respond(200, {versions: ["r0.4.0"]}); + httpBackend.when("GET", "/api/v1").respond(200, {}); + return completeLogin(matrixChat).then(() => { // we should see a home page, even though we previously had // a stored mx_last_room_id