diff --git a/moodle.config.json b/moodle.config.json index fc2e939e3..1470c520d 100644 --- a/moodle.config.json +++ b/moodle.config.json @@ -122,5 +122,6 @@ "font-awesome": ["fam"], "moodle": ["moodle"] } - } + }, + "clearIABSessionWhenAutoLogin": "android" } diff --git a/src/core/classes/sites/site.ts b/src/core/classes/sites/site.ts index 9e695d783..2a8af678a 100644 --- a/src/core/classes/sites/site.ts +++ b/src/core/classes/sites/site.ts @@ -54,6 +54,7 @@ import { CoreFilepool } from '@services/filepool'; import { CoreSiteInfo } from './unauthenticated-site'; import { CoreAuthenticatedSite, CoreAuthenticatedSiteOptionalData, CoreSiteWSPreSets, WSObservable } from './authenticated-site'; import { firstValueFrom } from 'rxjs'; +import { CorePlatform } from '@services/platform'; /** * Class that represents a site (combination of site + user). @@ -557,6 +558,17 @@ export class CoreSite extends CoreAuthenticatedSite { // Open the URL. if (inApp) { + if ( + options.clearsessioncache === undefined && autoLoginUrl !== url && + ( + CoreConstants.CONFIG.clearIABSessionWhenAutoLogin === 'all' || + (CoreConstants.CONFIG.clearIABSessionWhenAutoLogin === 'android' && CorePlatform.isAndroid()) || + (CoreConstants.CONFIG.clearIABSessionWhenAutoLogin === 'ios' && CorePlatform.isIOS()) + ) + ) { + options.clearsessioncache = 'yes'; + } + return CoreUtils.openInApp(autoLoginUrl, options); } else { return CoreUtils.openInBrowser(autoLoginUrl, options); diff --git a/src/types/config.d.ts b/src/types/config.d.ts index 2b6f6ffc1..cda618cf6 100644 --- a/src/types/config.d.ts +++ b/src/types/config.d.ts @@ -76,4 +76,5 @@ export interface EnvironmentConfig { demoMode?: boolean; // Whether to run the app in "demo mode". hideInformativeLinks?: boolean; // Whether to hide informative links. iconsPrefixes?: Record>; // Prefixes for custom font icons (located in src/assets/fonts). + clearIABSessionWhenAutoLogin?: 'android' | 'ios' | 'all'; // Clear the session every time a new IAB is opened with auto-login. }