Merge pull request #2035 from crazyserver/MOBILE-3081

MOBILE-3081 login: Show download button on version check
main
Juan Leyva 2019-08-01 10:33:29 +02:00 committed by GitHub
commit 6b3802bb3a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 31 additions and 12 deletions

View File

@ -220,6 +220,9 @@ export class CoreLoginCredentialsPage {
});
}).catch((error) => {
this.loginHelper.treatUserTokenError(siteUrl, error, username, password);
if (error.loggedout) {
this.navCtrl.setRoot('CoreLoginSitesPage');
}
}).finally(() => {
modal.dismiss();
});

View File

@ -94,14 +94,8 @@ export class CoreLoginInitPage {
return this.loadPage();
});
}
} else {
return this.sitesProvider.hasSites().then((hasSites) => {
if (hasSites) {
return this.navCtrl.setRoot('CoreLoginSitesPage');
} else {
return this.loginHelper.goToAddSite(true);
}
});
}
return this.navCtrl.setRoot('CoreLoginSitesPage');
}
}

View File

@ -103,7 +103,9 @@ export class CoreLoginReconnectPage {
* Cancel reconnect.
*/
cancel(): void {
this.sitesProvider.logout().finally(() => {
this.sitesProvider.logout().catch(() => {
// Ignore errors (shouldn't happen).
}).finally(() => {
this.navCtrl.setRoot('CoreLoginSitesPage');
});
}
@ -149,13 +151,22 @@ export class CoreLoginReconnectPage {
// Go to the site initial page.
return this.loginHelper.goToSiteInitialPage(this.navCtrl, this.pageName, this.pageParams);
}).catch((error) => {
if (error.loggedout) {
this.loginHelper.treatUserTokenError(siteUrl, error, username, password);
} else {
this.domUtils.showErrorModalDefault(error, 'core.login.errorupdatesite', true);
}
// Error, go back to login page.
this.domUtils.showErrorModalDefault(error, 'core.login.errorupdatesite', true);
this.cancel();
});
});
}).catch((error) => {
this.loginHelper.treatUserTokenError(siteUrl, error, username, password);
if (error.loggedout) {
this.cancel();
}
}).finally(() => {
modal.dismiss();
});

View File

@ -95,10 +95,16 @@ export class CoreLoginSitePage {
return this.sitesProvider.newSite(data.siteUrl, data.token, data.privateToken).then(() => {
return this.loginHelper.goToSiteInitialPage();
}, (error) => {
this.domUtils.showErrorModal(error);
this.loginHelper.treatUserTokenError(siteData.url, error, siteData.username, siteData.password);
if (error.loggedout) {
this.navCtrl.setRoot('CoreLoginSitesPage');
}
});
}, (error) => {
this.loginHelper.treatUserTokenError(siteData.url, error, siteData.username, siteData.password);
if (error.loggedout) {
this.navCtrl.setRoot('CoreLoginSitesPage');
}
}).finally(() => {
modal.dismiss();
});

View File

@ -46,6 +46,10 @@ export class CoreLoginSitesPage {
*/
ionViewDidLoad(): void {
this.sitesProvider.getSortedSites().then((sites) => {
if (sites.length == 0) {
this.loginHelper.goToAddSite(true);
}
// Remove protocol from the url to show more url text.
this.sites = sites.map((site) => {
site.siteUrl = site.siteUrl.replace(/^https?:\/\//, '');

View File

@ -715,7 +715,8 @@ export class CoreSitesProvider {
return promise.then(() => {
return Promise.reject({
error: this.translate.instant(errorKey, errorKeyParams) + errorExtra,
errorcode: errorCode
errorcode: errorCode,
loggedout: true
});
});
}