MOBILE-3320 login: Fix application check

main
Noel De Martin 2021-05-05 17:52:40 +02:00
parent d9b55440df
commit a16c3d3ce6
2 changed files with 42 additions and 39 deletions

View File

@ -348,7 +348,8 @@ export class CoreLoginSitePage implements OnInit {
* @return Promise resolved after logging in. * @return Promise resolved after logging in.
*/ */
protected async login(response: CoreSiteCheckResponse, foundSite?: CoreLoginSiteInfoExtended): Promise<void> { protected async login(response: CoreSiteCheckResponse, foundSite?: CoreLoginSiteInfoExtended): Promise<void> {
await CoreUtils.ignoreErrors(CoreSites.checkApplication(response)); try {
await CoreSites.checkApplication(response);
CoreForms.triggerFormSubmittedEvent(this.formElement, true); CoreForms.triggerFormSubmittedEvent(this.formElement, true);
@ -375,6 +376,9 @@ export class CoreLoginSitePage implements OnInit {
params: pageParams, params: pageParams,
}); });
} }
} catch (error) {
// Ignore errors.
}
} }
/** /**

View File

@ -1174,13 +1174,15 @@ export class CoreSitesProvider {
* @return Promise resolved when the user is logged out. * @return Promise resolved when the user is logged out.
*/ */
async logout(): Promise<void> { async logout(): Promise<void> {
let siteId: string | undefined; if (!this.currentSite) {
const promises: Promise<unknown>[] = []; return;
}
if (this.currentSite) {
const db = await this.appDB; const db = await this.appDB;
const promises: Promise<unknown>[] = [];
const siteConfig = this.currentSite.getStoredConfig(); const siteConfig = this.currentSite.getStoredConfig();
siteId = this.currentSite.getId(); const siteId = this.currentSite.getId();
this.currentSite = undefined; this.currentSite = undefined;
@ -1189,14 +1191,11 @@ export class CoreSitesProvider {
} }
promises.push(db.deleteRecords(CURRENT_SITE_TABLE_NAME, { id: 1 })); promises.push(db.deleteRecords(CURRENT_SITE_TABLE_NAME, { id: 1 }));
}
try { await CoreUtils.ignoreErrors(Promise.all(promises));
await Promise.all(promises);
} finally {
CoreEvents.trigger(CoreEvents.LOGOUT, {}, siteId); CoreEvents.trigger(CoreEvents.LOGOUT, {}, siteId);
} }
}
/** /**
* Restores the session to the previous one so the user doesn't has to login everytime the app is started. * Restores the session to the previous one so the user doesn't has to login everytime the app is started.