Merge pull request #2779 from dpalou/MOBILE-3716

Mobile 3716
main
Pau Ferrer Ocaña 2021-05-19 15:57:39 +02:00 committed by GitHub
commit 1edcae5188
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 18 additions and 21 deletions

View File

@ -28,6 +28,7 @@ import { CoreCustomURLSchemes } from '@services/urlschemes';
import { CoreUtils } from '@services/utils/utils';
import { CoreUrlUtils } from '@services/utils/url';
import { CoreConstants } from '@/core/constants';
import { CoreSitePlugins } from '@features/siteplugins/services/siteplugins';
const MOODLE_VERSION_PREFIX = 'version-';
const MOODLEAPP_VERSION_PREFIX = 'moodleapp-';
@ -61,15 +62,20 @@ export class AppComponent implements OnInit, AfterViewInit {
document.body.classList.add('ionic5');
this.addVersionClass(MOODLEAPP_VERSION_PREFIX, CoreConstants.CONFIG.versionname.replace('-dev', ''));
CoreEvents.on(CoreEvents.LOGOUT, () => {
// Go to sites page when user is logged out.
CoreNavigator.navigate('/login/sites', { reset: true });
CoreEvents.on(CoreEvents.LOGOUT, async () => {
// Unload lang custom strings.
CoreLang.clearCustomStrings();
// Remove version classes from body.
this.removeVersionClass(MOODLE_VERSION_PREFIX);
// Go to sites page when user is logged out.
await CoreNavigator.navigate('/login/sites', { reset: true });
if (CoreSitePlugins.hasSitePluginsLoaded) {
// Temporary fix. Reload the page to unload all plugins.
window.location.reload();
}
});
// Listen for session expired events.

View File

@ -146,7 +146,7 @@ export class CoreSite {
* @return Site ID.
*/
getId(): string {
if (!this.id) {
if (this.id === undefined) {
// Shouldn't happen for authenticated sites.
throw new CoreError('This site doesn\'t have an ID');
}
@ -169,7 +169,7 @@ export class CoreSite {
* @return Site token.
*/
getToken(): string {
if (!this.token) {
if (this.token === undefined) {
// Shouldn't happen for authenticated sites.
throw new CoreError('This site doesn\'t have a token');
}

View File

@ -62,7 +62,6 @@ export class CoreLoginReconnectPage implements OnInit, OnDestroy {
constructor(
protected fb: FormBuilder,
) {
const currentSite = CoreSites.getCurrentSite();
this.isLoggedOut = !!currentSite?.isLoggedOut();
@ -80,7 +79,7 @@ export class CoreLoginReconnectPage implements OnInit, OnDestroy {
return this.cancel();
}
this.siteUrl = siteId;
this.siteId = siteId;
this.page = CoreNavigator.getRouteParam('pageName');
this.pageOptions = CoreNavigator.getRouteParam('pageOptions');
this.showScanQR = CoreLoginHelper.displayQRInSiteScreen() || CoreLoginHelper.displayQRInCredentialsScreen();

View File

@ -903,12 +903,12 @@ export class CoreLoginHelperProvider {
if (!CoreApp.isSSOAuthenticationOngoing() && !this.isSSOConfirmShown && !this.waitingForBrowser) {
this.isSSOConfirmShown = true;
try {
if (this.shouldShowSSOConfirm(result.code)) {
await CoreDomUtils.showConfirm(Translate.instant('core.login.' +
(currentSite.isLoggedOut() ? 'loggedoutssodescription' : 'reconnectssodescription')));
}
try {
this.waitingForBrowser = true;
this.openBrowserForSSOLogin(

View File

@ -135,14 +135,6 @@ export class CoreSitePluginsHelperProvider {
}
});
// Unload plugins on logout if any.
CoreEvents.on(CoreEvents.LOGOUT, () => {
if (CoreSitePlugins.hasSitePluginsLoaded) {
// Temporary fix. Reload the page to unload all plugins.
window.location.reload();
}
});
// Re-load plugins restricted for courses when the list of user courses changes.
CoreEvents.on(CoreCoursesProvider.EVENT_MY_COURSES_CHANGED, (data) => {
if (data && data.siteId && data.siteId == CoreSites.getCurrentSiteId() && data.added && data.added.length) {