Merge pull request #2350 from dpalou/MOBILE-3384

MOBILE-3384 login: Accept null in local_mobile check response
main
Juan Leyva 2020-04-28 16:55:08 +02:00 committed by GitHub
commit 0b81dd4c5d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 1 deletions

View File

@ -1376,6 +1376,11 @@ export class CoreSite {
return { code: 0 }; 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 (typeof data != 'undefined' && data.errorcode === 'requirecorrectaccess') {
if (!retrying) { if (!retrying) {
this.siteUrl = this.urlUtils.addOrRemoveWWW(this.siteUrl); this.siteUrl = this.urlUtils.addOrRemoveWWW(this.siteUrl);

View File

@ -165,7 +165,14 @@ export class CoreLoginSitePage {
// Attempt guessing the domain if the initial check failed // Attempt guessing the domain if the initial check failed
const domain = CoreUrl.guessMoodleDomain(url); 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)) .then((result) => this.login(result))
.catch((error) => this.showLoginIssue(url, error)) .catch((error) => this.showLoginIssue(url, error))

View File

@ -572,6 +572,11 @@ export class CoreSitesProvider {
return Promise.reject({error: this.translate.instant('core.cannotconnect', {$a: CoreSite.MINIMUM_MOODLE_VERSION})}); return Promise.reject({error: this.translate.instant('core.cannotconnect', {$a: CoreSite.MINIMUM_MOODLE_VERSION})});
}).then((data: any) => { }).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')) { if (data.errorcode && (data.errorcode == 'enablewsdescription' || data.errorcode == 'requirecorrectaccess')) {
return Promise.reject({ errorcode: data.errorcode, error: data.error }); return Promise.reject({ errorcode: data.errorcode, error: data.error });
} else if (data.error && data.error == 'Web services must be enabled in Advanced features.') { } else if (data.error && data.error == 'Web services must be enabled in Advanced features.') {