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.
|
* @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);
|
||||||
|
|
||||||
if (response.warning) {
|
if (response.warning) {
|
||||||
CoreDomUtils.showErrorModal(response.warning, true, 4000);
|
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CoreNavigator.navigate('/login/credentials', {
|
if (CoreLoginHelper.isSSOLoginNeeded(response.code)) {
|
||||||
params: pageParams,
|
// 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.
|
* @return Promise resolved when the user is logged out.
|
||||||
*/
|
*/
|
||||||
async logout(): Promise<void> {
|
async logout(): Promise<void> {
|
||||||
let siteId: string | undefined;
|
if (!this.currentSite) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const db = await this.appDB;
|
||||||
|
|
||||||
const promises: Promise<unknown>[] = [];
|
const promises: Promise<unknown>[] = [];
|
||||||
|
const siteConfig = this.currentSite.getStoredConfig();
|
||||||
|
const siteId = this.currentSite.getId();
|
||||||
|
|
||||||
if (this.currentSite) {
|
this.currentSite = undefined;
|
||||||
const db = await this.appDB;
|
|
||||||
const siteConfig = this.currentSite.getStoredConfig();
|
|
||||||
siteId = this.currentSite.getId();
|
|
||||||
|
|
||||||
this.currentSite = undefined;
|
if (siteConfig && siteConfig.tool_mobile_forcelogout == '1') {
|
||||||
|
promises.push(this.setSiteLoggedOut(siteId, true));
|
||||||
if (siteConfig && siteConfig.tool_mobile_forcelogout == '1') {
|
|
||||||
promises.push(this.setSiteLoggedOut(siteId, true));
|
|
||||||
}
|
|
||||||
|
|
||||||
promises.push(db.deleteRecords(CURRENT_SITE_TABLE_NAME, { id: 1 }));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
promises.push(db.deleteRecords(CURRENT_SITE_TABLE_NAME, { id: 1 }));
|
||||||
await Promise.all(promises);
|
|
||||||
} finally {
|
await CoreUtils.ignoreErrors(Promise.all(promises));
|
||||||
CoreEvents.trigger(CoreEvents.LOGOUT, {}, siteId);
|
|
||||||
}
|
CoreEvents.trigger(CoreEvents.LOGOUT, {}, siteId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue