diff --git a/moodle.config.json b/moodle.config.json index 061b6a3ed..b61f913ea 100644 --- a/moodle.config.json +++ b/moodle.config.json @@ -85,8 +85,7 @@ "high": 120 }, "customurlscheme": "moodlemobile", - "siteurl": "", - "sitename": "", + "sites": [], "multisitesdisplay": "", "sitefindersettings": {}, "onlyallowlistedsites": false, diff --git a/src/addons/storagemanager/pages/courses-storage/courses-storage.ts b/src/addons/storagemanager/pages/courses-storage/courses-storage.ts index 1266f98bf..9e9eb145e 100644 --- a/src/addons/storagemanager/pages/courses-storage/courses-storage.ts +++ b/src/addons/storagemanager/pages/courses-storage/courses-storage.ts @@ -261,7 +261,8 @@ export class AddonStorageManagerCoursesStoragePage implements OnInit, OnDestroy event.stopPropagation(); try { - const siteName = CoreSites.getRequiredCurrentSite().getSiteName(); + const site = CoreSites.getRequiredCurrentSite(); + const siteName = await site.getSiteName(); this.spaceUsage = await CoreSettingsHelper.deleteSiteStorage(siteName, this.siteId); } catch { diff --git a/src/core/classes/site.ts b/src/core/classes/site.ts index 6fffa7b91..ac7b946e1 100644 --- a/src/core/classes/site.ts +++ b/src/core/classes/site.ts @@ -61,6 +61,7 @@ import { finalize, map, mergeMap } from 'rxjs/operators'; import { firstValueFrom } from '../utils/rxjs'; import { CoreSiteError } from '@classes/errors/siteerror'; import { CoreUserAuthenticatedSupportConfig } from '@features/user/classes/support/authenticated-support-config'; +import { CoreLoginHelper } from '@features/login/services/login-helper'; /** * QR Code type enumeration. @@ -289,13 +290,21 @@ export class CoreSite { * * @returns Site name. */ - getSiteName(): string { - if (CoreConstants.CONFIG.sitename) { - // Overridden by config. - return CoreConstants.CONFIG.sitename; - } else { - return this.infos?.sitename || ''; + async getSiteName(): Promise { + if (this.infos?.sitename) { + return this.infos?.sitename; } + + // Fallback. + const isSigleFixedSite = await CoreLoginHelper.isSingleFixedSite(); + + if (isSigleFixedSite) { + const sites = await CoreLoginHelper.getAvailableSites(); + + return sites[0].name; + } + + return ''; } /** diff --git a/src/core/components/show-password/show-password.ts b/src/core/components/show-password/show-password.ts index 3b61044bf..735a4c4c5 100644 --- a/src/core/components/show-password/show-password.ts +++ b/src/core/components/show-password/show-password.ts @@ -65,9 +65,14 @@ export class CoreShowPasswordComponent implements OnInit, AfterViewInit { */ async ngAfterViewInit(): Promise { if (this.ionInput) { - // It's an ion-input, use it to get the native element. - this.input = await this.ionInput.getInputElement(); - this.setData(this.input); + try { + // It's an ion-input, use it to get the native element. + this.input = await this.ionInput.getInputElement(); + this.setData(this.input); + } catch (error) { + // This should never fail, but it does in some testing environment because Ionic elements are not + // rendered properly. So in case this fails, we'll just ignore the error. + } return; } diff --git a/src/core/features/courses/pages/my/my.ts b/src/core/features/courses/pages/my/my.ts index 99c212873..c9d956500 100644 --- a/src/core/features/courses/pages/my/my.ts +++ b/src/core/features/courses/pages/my/my.ts @@ -61,9 +61,9 @@ export class CoreCoursesMyPage implements OnInit, OnDestroy, AsyncDirective { constructor(protected loadsManager: PageLoadsManager) { // Refresh the enabled flags if site is updated. - this.updateSiteObserver = CoreEvents.on(CoreEvents.SITE_UPDATED, () => { + this.updateSiteObserver = CoreEvents.on(CoreEvents.SITE_UPDATED, async () => { this.downloadCoursesEnabled = !CoreCourses.isDownloadCoursesDisabledInSite(); - this.loadSiteName(); + await this.loadSiteName(); }, CoreSites.getCurrentSiteId()); @@ -78,13 +78,13 @@ export class CoreCoursesMyPage implements OnInit, OnDestroy, AsyncDirective { /** * @inheritdoc */ - ngOnInit(): void { + async ngOnInit(): Promise { this.downloadCoursesEnabled = !CoreCourses.isDownloadCoursesDisabledInSite(); const deepLinkManager = new CoreMainMenuDeepLinkManager(); deepLinkManager.treatLink(); - this.loadSiteName(); + await this.loadSiteName(); this.loadContent(true); } @@ -143,8 +143,9 @@ export class CoreCoursesMyPage implements OnInit, OnDestroy, AsyncDirective { /** * Load the site name. */ - protected loadSiteName(): void { - this.siteName = CoreSites.getRequiredCurrentSite().getSiteName() || ''; + protected async loadSiteName(): Promise { + const site = CoreSites.getRequiredCurrentSite(); + this.siteName = await site.getSiteName() || ''; } /** diff --git a/src/core/features/login/guards/has-sites.ts b/src/core/features/login/guards/has-sites.ts index 8a8a6ef20..a96745941 100644 --- a/src/core/features/login/guards/has-sites.ts +++ b/src/core/features/login/guards/has-sites.ts @@ -50,7 +50,7 @@ export class CoreLoginHasSitesGuard implements CanActivate, CanLoad { return true; } - const [path, params] = CoreLoginHelper.getAddSiteRouteInfo(); + const [path, params] = await CoreLoginHelper.getAddSiteRouteInfo(); const route = Router.parseUrl(path); route.queryParams = params; diff --git a/src/core/features/login/pages/credentials/credentials.ts b/src/core/features/login/pages/credentials/credentials.ts index 5841c1e7e..f5a0517c4 100644 --- a/src/core/features/login/pages/credentials/credentials.ts +++ b/src/core/features/login/pages/credentials/credentials.ts @@ -56,7 +56,6 @@ export class CoreLoginCredentialsPage implements OnInit, OnDestroy { identityProviders?: CoreSiteIdentityProvider[]; pageLoaded = false; isBrowserSSO = false; - isFixedUrlSet = false; showForgottenPassword = true; showScanQR = false; loginAttempts = 0; @@ -99,9 +98,10 @@ export class CoreLoginCredentialsPage implements OnInit, OnDestroy { if (this.siteConfig) { this.treatSiteConfig(); } - this.isFixedUrlSet = CoreLoginHelper.isFixedUrlSet(); - if (this.isFixedUrlSet || !this.siteConfig) { + const isSingleFixedSite = await CoreLoginHelper.isSingleFixedSite(); + + if (isSingleFixedSite || !this.siteConfig) { // Fixed URL or not siteConfig retrieved from params, we need to check if it uses browser SSO login. this.checkSite(this.siteUrl, true); } else { @@ -198,12 +198,12 @@ export class CoreLoginCredentialsPage implements OnInit, OnDestroy { /** * Treat the site configuration (if it exists). */ - protected treatSiteConfig(): void { + protected async treatSiteConfig(): Promise { if (this.siteConfig) { - this.siteName = CoreConstants.CONFIG.sitename ? CoreConstants.CONFIG.sitename : this.siteConfig.sitename; + this.siteName = this.siteConfig.sitename; this.logoUrl = CoreLoginHelper.getLogoUrl(this.siteConfig); this.authInstructions = this.siteConfig.authinstructions || Translate.instant('core.login.loginsteps'); - this.showScanQR = CoreLoginHelper.displayQRInCredentialsScreen(this.siteConfig.tool_mobile_qrcodetype); + this.showScanQR = await CoreLoginHelper.displayQRInCredentialsScreen(this.siteConfig.tool_mobile_qrcodetype); const disabledFeatures = CoreLoginHelper.getDisabledFeatures(this.siteConfig); this.identityProviders = CoreLoginHelper.getValidIdentityProviders(this.siteConfig, disabledFeatures); diff --git a/src/core/features/login/pages/email-signup/email-signup.ts b/src/core/features/login/pages/email-signup/email-signup.ts index ca3879c07..253d20fdc 100644 --- a/src/core/features/login/pages/email-signup/email-signup.ts +++ b/src/core/features/login/pages/email-signup/email-signup.ts @@ -20,7 +20,6 @@ import { CoreDomUtils } from '@services/utils/dom'; import { CoreTextUtils } from '@services/utils/text'; import { CoreCountry, CoreUtils } from '@services/utils/utils'; import { CoreWS, CoreWSExternalWarning } from '@services/ws'; -import { CoreConstants } from '@/core/constants'; import { Translate } from '@singletons'; import { CoreSitePublicConfigResponse } from '@classes/site'; import { CoreUserProfileFieldDelegate } from '@features/user/services/user-profile-field-delegate'; @@ -235,7 +234,7 @@ export class CoreLoginEmailSignupPage implements OnInit { */ protected treatSiteConfig(): boolean { if (this.siteConfig?.registerauth == 'email' && !CoreLoginHelper.isEmailSignupDisabled(this.siteConfig)) { - this.siteName = CoreConstants.CONFIG.sitename ? CoreConstants.CONFIG.sitename : this.siteConfig.sitename; + this.siteName = this.siteConfig.sitename; this.authInstructions = this.siteConfig.authinstructions; this.ageDigitalConsentVerification = this.siteConfig.agedigitalconsentverification; this.supportName = this.siteConfig.supportname; diff --git a/src/core/features/login/pages/reconnect/reconnect.html b/src/core/features/login/pages/reconnect/reconnect.html index 081d6a1d7..825c3315e 100644 --- a/src/core/features/login/pages/reconnect/reconnect.html +++ b/src/core/features/login/pages/reconnect/reconnect.html @@ -18,12 +18,12 @@
-
+
- {{ 'core.pictureof' | translate:{$a: userFullName} }} -