diff --git a/src/classes/site.ts b/src/classes/site.ts index befacd29e..a3dda67a2 100644 --- a/src/classes/site.ts +++ b/src/classes/site.ts @@ -1376,6 +1376,11 @@ export class CoreSite { return { code: 0 }; } + if (data === null) { + // This probably means that the server was configured to return null for non-existing URLs. Not installed. + return { code: 0 }; + } + if (typeof data != 'undefined' && data.errorcode === 'requirecorrectaccess') { if (!retrying) { this.siteUrl = this.urlUtils.addOrRemoveWWW(this.siteUrl); diff --git a/src/core/login/pages/site/site.ts b/src/core/login/pages/site/site.ts index 400491069..59b87f862 100644 --- a/src/core/login/pages/site/site.ts +++ b/src/core/login/pages/site/site.ts @@ -165,7 +165,14 @@ export class CoreLoginSitePage { // Attempt guessing the domain if the initial check failed const domain = CoreUrl.guessMoodleDomain(url); - return domain ? this.sitesProvider.checkSite(domain) : Promise.reject(error); + if (domain && domain != url) { + return this.sitesProvider.checkSite(domain).catch((secondError) => { + // Try to use the first error. + return Promise.reject(error || secondError); + }); + } + + return Promise.reject(error); }) .then((result) => this.login(result)) .catch((error) => this.showLoginIssue(url, error)) diff --git a/src/providers/sites.ts b/src/providers/sites.ts index f0f85df99..22d42b4e0 100644 --- a/src/providers/sites.ts +++ b/src/providers/sites.ts @@ -572,6 +572,11 @@ export class CoreSitesProvider { return Promise.reject({error: this.translate.instant('core.cannotconnect', {$a: CoreSite.MINIMUM_MOODLE_VERSION})}); }).then((data: any) => { + if (data === null) { + // Cannot connect. + return Promise.reject({error: this.translate.instant('core.cannotconnect', {$a: CoreSite.MINIMUM_MOODLE_VERSION})}); + } + if (data.errorcode && (data.errorcode == 'enablewsdescription' || data.errorcode == 'requirecorrectaccess')) { return Promise.reject({ errorcode: data.errorcode, error: data.error }); } else if (data.error && data.error == 'Web services must be enabled in Advanced features.') {