Merge pull request #2061 from dpalou/MOBILE-3106

MOBILE-3106 login: Check redirect if get site info fails
main
Juan Leyva 2019-08-21 10:18:22 +01:00 committed by GitHub
commit 3da5e07f1a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 1 deletions

View File

@ -1454,7 +1454,15 @@ export class CoreSite {
preSets.noLogin = true;
preSets.useGet = true;
return this.wsProvider.callAjax('tool_mobile_get_public_config', {}, preSets);
return this.wsProvider.callAjax('tool_mobile_get_public_config', {}, preSets).catch((error2) => {
if (this.getInfo() && this.isVersionGreaterEqualThan('3.8')) {
// GET is supported, return the second error.
return Promise.reject(error2);
} else {
// GET not supported or we don't know if it's supported. Return first error.
return Promise.reject(error);
}
});
}
return Promise.reject(error);

View File

@ -470,6 +470,20 @@ export class CoreSitesProvider {
// Service supported but an error happened. Return error.
error.critical = true;
if (error.errorcode == 'codingerror') {
// This could be caused by a redirect. Check if it's the case.
return this.utils.checkRedirect(siteUrl).then((redirect) => {
if (redirect) {
error.error = this.translate.instant('core.login.sitehasredirect');
} else {
// We can't be sure if there is a redirect or not. Display cannot connect error.
error.error = this.translate.instant('core.cannotconnect');
}
return Promise.reject(error);
});
}
return Promise.reject(error);
}