MOBILE-4604 iab: Clear session when open IAB with auto-login in Android

main
Dani Palou 2024-06-05 11:56:59 +02:00
parent ac920dc299
commit 0b9cab2aeb
3 changed files with 15 additions and 1 deletions

View File

@ -122,5 +122,6 @@
"font-awesome": ["fam"],
"moodle": ["moodle"]
}
}
},
"clearIABSessionWhenAutoLogin": "android"
}

View File

@ -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);

View File

@ -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<string, Record<string, string[]>>; // 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.
}