MOBILE-3320 login: Fix application check
parent
d9b55440df
commit
a16c3d3ce6
|
@ -348,32 +348,36 @@ export class CoreLoginSitePage implements OnInit {
|
|||
* @return Promise resolved after logging in.
|
||||
*/
|
||||
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);
|
||||
|
||||
if (response.warning) {
|
||||
CoreDomUtils.showErrorModal(response.warning, true, 4000);
|
||||
}
|
||||
|
||||
if (CoreLoginHelper.isSSOLoginNeeded(response.code)) {
|
||||
// SSO. User needs to authenticate in a browser.
|
||||
CoreLoginHelper.confirmAndOpenBrowserForSSOLogin(
|
||||
response.siteUrl,
|
||||
response.code,
|
||||
response.service,
|
||||
response.config?.launchurl,
|
||||
);
|
||||
} else {
|
||||
const pageParams = { siteUrl: response.siteUrl, siteConfig: response.config };
|
||||
if (foundSite && !this.fixedSites) {
|
||||
pageParams['siteName'] = foundSite.name;
|
||||
pageParams['logoUrl'] = foundSite.imageurl;
|
||||
if (response.warning) {
|
||||
CoreDomUtils.showErrorModal(response.warning, true, 4000);
|
||||
}
|
||||
|
||||
CoreNavigator.navigate('/login/credentials', {
|
||||
params: pageParams,
|
||||
});
|
||||
if (CoreLoginHelper.isSSOLoginNeeded(response.code)) {
|
||||
// SSO. User needs to authenticate in a browser.
|
||||
CoreLoginHelper.confirmAndOpenBrowserForSSOLogin(
|
||||
response.siteUrl,
|
||||
response.code,
|
||||
response.service,
|
||||
response.config?.launchurl,
|
||||
);
|
||||
} else {
|
||||
const pageParams = { siteUrl: response.siteUrl, siteConfig: response.config };
|
||||
if (foundSite && !this.fixedSites) {
|
||||
pageParams['siteName'] = foundSite.name;
|
||||
pageParams['logoUrl'] = foundSite.imageurl;
|
||||
}
|
||||
|
||||
CoreNavigator.navigate('/login/credentials', {
|
||||
params: pageParams,
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
// Ignore errors.
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1174,28 +1174,27 @@ export class CoreSitesProvider {
|
|||
* @return Promise resolved when the user is logged out.
|
||||
*/
|
||||
async logout(): Promise<void> {
|
||||
let siteId: string | undefined;
|
||||
if (!this.currentSite) {
|
||||
return;
|
||||
}
|
||||
|
||||
const db = await this.appDB;
|
||||
|
||||
const promises: Promise<unknown>[] = [];
|
||||
const siteConfig = this.currentSite.getStoredConfig();
|
||||
const siteId = this.currentSite.getId();
|
||||
|
||||
if (this.currentSite) {
|
||||
const db = await this.appDB;
|
||||
const siteConfig = this.currentSite.getStoredConfig();
|
||||
siteId = this.currentSite.getId();
|
||||
this.currentSite = undefined;
|
||||
|
||||
this.currentSite = undefined;
|
||||
|
||||
if (siteConfig && siteConfig.tool_mobile_forcelogout == '1') {
|
||||
promises.push(this.setSiteLoggedOut(siteId, true));
|
||||
}
|
||||
|
||||
promises.push(db.deleteRecords(CURRENT_SITE_TABLE_NAME, { id: 1 }));
|
||||
if (siteConfig && siteConfig.tool_mobile_forcelogout == '1') {
|
||||
promises.push(this.setSiteLoggedOut(siteId, true));
|
||||
}
|
||||
|
||||
try {
|
||||
await Promise.all(promises);
|
||||
} finally {
|
||||
CoreEvents.trigger(CoreEvents.LOGOUT, {}, siteId);
|
||||
}
|
||||
promises.push(db.deleteRecords(CURRENT_SITE_TABLE_NAME, { id: 1 }));
|
||||
|
||||
await CoreUtils.ignoreErrors(Promise.all(promises));
|
||||
|
||||
CoreEvents.trigger(CoreEvents.LOGOUT, {}, siteId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue