Skip to content

Commit

Permalink
MOBILE-4604 iab: Clear session when open IAB with auto-login in Android
Browse files Browse the repository at this point in the history
  • Loading branch information
dpalou committed Jun 5, 2024
1 parent ac920dc commit 0b9cab2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
3 changes: 2 additions & 1 deletion moodle.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,5 +122,6 @@
"font-awesome": ["fam"],
"moodle": ["moodle"]
}
}
},
"clearIABSessionWhenAutoLogin": "android"
}
12 changes: 12 additions & 0 deletions src/core/classes/sites/site.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/types/config.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
}

0 comments on commit 0b9cab2

Please sign in to comment.