diff --git a/src/core/components/iframe/iframe.ts b/src/core/components/iframe/iframe.ts index fdd472b85f8..5836438b984 100644 --- a/src/core/components/iframe/iframe.ts +++ b/src/core/components/iframe/iframe.ts @@ -30,6 +30,7 @@ import { CoreSites } from '@services/sites'; import { toBoolean } from '@/core/transforms/boolean'; import { CoreDom } from '@singletons/dom'; import { CoreAlerts } from '@services/overlays/alerts'; +import { CoreLang, CoreLangFormat } from '@services/lang'; @Component({ selector: 'core-iframe', @@ -234,9 +235,16 @@ export class CoreIframeComponent implements OnChanges, OnDestroy { this.displayHelp = CoreIframeUtils.shouldDisplayHelpForUrl(url); const currentSite = CoreSites.getCurrentSite(); - if (this.allowAutoLogin && currentSite) { - // Format the URL to add auto-login if needed. - url = await currentSite.getAutoLoginUrl(url, false); + if (currentSite?.containsUrl(url)) { + // Format the URL to add auto-login if needed and add the lang parameter. + const autoLoginUrl = this.allowAutoLogin ? + await currentSite.getAutoLoginUrl(url, false) : + url; + + const lang = await CoreLang.getCurrentLanguage(CoreLangFormat.LMS); + url = CoreUrl.addParamsToUrl(autoLoginUrl, { lang }, { + checkAutoLoginUrl: autoLoginUrl !== url, + }); } if (currentSite?.isVersionGreaterEqualThan('3.7') && CoreUrl.isVimeoVideoUrl(url)) { diff --git a/src/core/directives/format-text.ts b/src/core/directives/format-text.ts index 9ad3c2ed52b..63857fe912d 100644 --- a/src/core/directives/format-text.ts +++ b/src/core/directives/format-text.ts @@ -60,6 +60,7 @@ import { toBoolean } from '../transforms/boolean'; import { CoreViewer } from '@features/viewer/services/viewer'; import { CorePromiseUtils } from '@singletons/promise-utils'; import { CoreAlerts } from '@services/overlays/alerts'; +import { CoreLang, CoreLangFormat } from '@services/lang'; /** * Directive to format text rendered. It renders the HTML and treats all links and media, using CoreLinkDirective @@ -833,7 +834,13 @@ export class CoreFormatTextDirective implements OnChanges, OnDestroy, AsyncDirec // Remove iframe src, otherwise it can cause auto-login issues if there are several iframes with auto-login. iframe.src = ''; - const finalUrl = await CoreIframeUtils.getAutoLoginUrlForIframe(iframe, src); + let finalUrl = await CoreIframeUtils.getAutoLoginUrlForIframe(iframe, src); + + const lang = await CoreLang.getCurrentLanguage(CoreLangFormat.LMS); + finalUrl = CoreUrl.addParamsToUrl(finalUrl, { lang }, { + checkAutoLoginUrl: src !== finalUrl, + }); + await CoreIframeUtils.fixIframeCookies(finalUrl); iframe.src = finalUrl;