{
this.updateHandlers();
}
});
+ CoreEvents.on(CoreEvents.COMPLETE_REQUIRED_PROFILE_DATA_FINISHED, (data) => {
+ if (data.siteId === CoreSites.getCurrentSiteId()) {
+ this.updateHandlers();
+ }
+ });
}
}
diff --git a/src/core/classes/site.ts b/src/core/classes/site.ts
index 3420106dc..31e0b3005 100644
--- a/src/core/classes/site.ts
+++ b/src/core/classes/site.ts
@@ -46,7 +46,6 @@ import { asyncInstance, AsyncInstance } from '../utils/async-instance';
import { CoreDatabaseTable } from './database/database-table';
import { CoreDatabaseCachingStrategy } from './database/database-table-proxy';
import { CoreSilentError } from './errors/silenterror';
-import { CoreWindow } from '@singletons/window';
/**
* QR Code type enumeration.
@@ -1608,16 +1607,7 @@ export class CoreSite {
if (inApp) {
return CoreUtils.openInApp(autoLoginUrl, options);
} else {
- if ((options.showBrowserWarning || options.showBrowserWarning === undefined) && autoLoginUrl !== url) {
- // Don't display the autologin URL in the warning.
- try {
- await CoreWindow.confirmOpenBrowserIfNeeded(url);
-
- options.showBrowserWarning = false;
- } catch (error) {
- return; // Cancelled, stop.
- }
- }
+ options.browserWarningUrl = url;
return CoreUtils.openInBrowser(autoLoginUrl, options);
}
diff --git a/src/core/components/local-file/core-local-file.html b/src/core/components/local-file/core-local-file.html
index b723da5eb..5814bf9c9 100644
--- a/src/core/components/local-file/core-local-file.html
+++ b/src/core/components/local-file/core-local-file.html
@@ -22,13 +22,13 @@
-
+
-
+
diff --git a/src/core/features/login/services/login-helper.ts b/src/core/features/login/services/login-helper.ts
index fb14d6eea..108cff604 100644
--- a/src/core/features/login/services/login-helper.ts
+++ b/src/core/features/login/services/login-helper.ts
@@ -37,6 +37,7 @@ import { CoreCanceledError } from '@classes/errors/cancelederror';
import { CoreCustomURLSchemes } from '@services/urlschemes';
import { CorePushNotifications } from '@features/pushnotifications/services/pushnotifications';
import { CoreText } from '@singletons/text';
+import { CorePromisedValue } from '@classes/promised-value';
/**
* Helper provider that provides some common features regarding authentication.
@@ -56,7 +57,7 @@ export class CoreLoginHelperProvider {
protected logger: CoreLogger;
protected sessionExpiredCheckingSite: Record = {};
protected isOpenEditAlertShown = false;
- protected waitingForBrowser = false;
+ protected waitingForBrowser?: CorePromisedValue;
constructor() {
this.logger = CoreLogger.getInstance('CoreLoginHelper');
@@ -768,11 +769,15 @@ export class CoreLoginHelperProvider {
try {
await currentSite.openInAppWithAutoLogin(siteUrl + path, undefined, alertMessage);
-
- this.waitingForBrowser = true;
} finally {
this.isOpenEditAlertShown = false;
}
+
+ await this.waitForBrowser();
+
+ CoreEvents.trigger(CoreEvents.COMPLETE_REQUIRED_PROFILE_DATA_FINISHED, {
+ path,
+ }, siteId);
}
}
@@ -917,7 +922,7 @@ export class CoreLoginHelperProvider {
(currentSite.isLoggedOut() ? 'loggedoutssodescription' : 'reconnectssodescription')));
}
- this.waitingForBrowser = true;
+ this.waitForBrowser();
this.openBrowserForSSOLogin(
result.siteUrl,
@@ -950,7 +955,7 @@ export class CoreLoginHelperProvider {
try {
await CoreDomUtils.showConfirm(confirmMessage);
- this.waitingForBrowser = true;
+ this.waitForBrowser();
CoreSites.unsetCurrentSite(); // Unset current site to make authentication work fine.
this.openBrowserForOAuthLogin(
@@ -1223,16 +1228,28 @@ export class CoreLoginHelperProvider {
* @return Whether the app is waiting for browser.
*/
isWaitingForBrowser(): boolean {
- return this.waitingForBrowser;
+ return !!this.waitingForBrowser;
}
/**
- * Set whether the app is waiting for browser.
+ * Start waiting when opening a browser/IAB.
*
- * @param value New value.
+ * @return Promise resolved when the app is resumed.
*/
- setWaitingForBrowser(value: boolean): void {
- this.waitingForBrowser = value;
+ async waitForBrowser(): Promise {
+ if (!this.waitingForBrowser) {
+ this.waitingForBrowser = new CorePromisedValue();
+ }
+
+ await this.waitingForBrowser;
+ }
+
+ /**
+ * Stop waiting for browser.
+ */
+ stopWaitingForBrowser(): void {
+ this.waitingForBrowser?.resolve();
+ this.waitingForBrowser = undefined;
}
/**
diff --git a/src/core/services/utils/utils.ts b/src/core/services/utils/utils.ts
index ef080cc23..0485bb253 100644
--- a/src/core/services/utils/utils.ts
+++ b/src/core/services/utils/utils.ts
@@ -1112,7 +1112,7 @@ export class CoreUtilsProvider {
async openInBrowser(url: string, options: CoreUtilsOpenInBrowserOptions = {}): Promise {
if (options.showBrowserWarning || options.showBrowserWarning === undefined) {
try {
- await CoreWindow.confirmOpenBrowserIfNeeded(url);
+ await CoreWindow.confirmOpenBrowserIfNeeded(options.browserWarningUrl ?? url);
} catch (error) {
return; // Cancelled, stop.
}
@@ -1836,6 +1836,7 @@ export type CoreUtilsOpenFileOptions = {
*/
export type CoreUtilsOpenInBrowserOptions = {
showBrowserWarning?: boolean; // Whether to display a warning before opening in browser. Defaults to true.
+ browserWarningUrl?: string; // The URL to display in the warning message. Use it to hide sensitive information.
};
/**
diff --git a/src/core/singletons/events.ts b/src/core/singletons/events.ts
index 9f303efa7..35f3968b2 100644
--- a/src/core/singletons/events.ts
+++ b/src/core/singletons/events.ts
@@ -61,6 +61,7 @@ export interface CoreEventsData {
[CoreEvents.APP_LAUNCHED_URL]: CoreEventAppLaunchedData;
[CoreEvents.ORIENTATION_CHANGE]: CoreEventOrientationData;
[CoreEvents.COURSE_MODULE_VIEWED]: CoreEventCourseModuleViewed;
+ [CoreEvents.COMPLETE_REQUIRED_PROFILE_DATA_FINISHED]: CoreEventCompleteRequiredProfileDataFinished;
}
/*
@@ -115,6 +116,7 @@ export class CoreEvents {
static readonly ACTIVITY_DATA_SENT = 'activity_data_sent';
static readonly DEVICE_REGISTERED_IN_MOODLE = 'device_registered_in_moodle';
static readonly COURSE_MODULE_VIEWED = 'course_module_viewed';
+ static readonly COMPLETE_REQUIRED_PROFILE_DATA_FINISHED = 'complete_required_profile_data_finished';
protected static logger = CoreLogger.getInstance('CoreEvents');
protected static observables: { [eventName: string]: Subject } = {};
@@ -467,3 +469,10 @@ export type CoreEventCourseModuleViewed = {
timeaccess: number;
sectionId?: number;
};
+
+/**
+ * Data passed to COMPLETE_REQUIRED_PROFILE_DATA_FINISHED event.
+ */
+export type CoreEventCompleteRequiredProfileDataFinished = {
+ path: string;
+};
diff --git a/src/core/singletons/window.ts b/src/core/singletons/window.ts
index 328fbbda6..95b94247c 100644
--- a/src/core/singletons/window.ts
+++ b/src/core/singletons/window.ts
@@ -61,6 +61,11 @@ export class CoreWindow {
return;
}
+ // Remove common sensitive information from the URL.
+ url = url
+ .replace(/token=[^]+/gi, 'token=secret')
+ .replace(/tokenpluginfile\.php\/[^/]+/gi, 'tokenpluginfile.php/secret');
+
const dontShowAgain = await CoreDomUtils.showPrompt(
Translate.instant('core.warnopeninbrowser', { url }),
undefined,
diff --git a/upgrade.txt b/upgrade.txt
index 2ee2fb749..b146617fb 100644
--- a/upgrade.txt
+++ b/upgrade.txt
@@ -25,7 +25,7 @@ information provided here is intended especially for developers.
- The variable "loaded" in CoreCourseModuleMainResourceComponent has been changed to "showLoading" to reflect its purpose better.
- The function getCurrentSection of course formats can now return a forceSelected boolean along with the section (defaults to false if not returned).
- The link handlers functions (CoreContentLinksHandler) will now always receive a relative URL instead of an absolute URL. The CoreContentLinksHandlerBase class now adds "^" to the start of the pattern by default to prevent false positives.
-
+- The function CoreLoginHelper.setWaitingForBrowser has been removed, use CoreLoginHelper.waitForBrowser and CoreLoginHelper.stopWaitingForBrowser instead.
=== 3.9.5 ===