diff --git a/src/core/features/login/pages/credentials/credentials.ts b/src/core/features/login/pages/credentials/credentials.ts index 35221ad9b..2bef573d0 100644 --- a/src/core/features/login/pages/credentials/credentials.ts +++ b/src/core/features/login/pages/credentials/credentials.ts @@ -34,6 +34,7 @@ import { SafeHtml } from '@angular/platform-browser'; import { CorePlatform } from '@services/platform'; import { CoreSitesFactory } from '@services/sites-factory'; import { EMAIL_SIGNUP_FEATURE_NAME, FORGOTTEN_PASSWORD_FEATURE_NAME } from '@features/login/constants'; +import { CoreCustomURLSchemes } from '@services/urlschemes'; /** * Page to enter the user credentials. @@ -107,7 +108,10 @@ export class CoreLoginCredentialsPage implements OnInit, OnDestroy { await this.checkSite(); if (this.isBrowserSSO && CoreLoginHelper.shouldSkipCredentialsScreenOnSSO()) { - this.openBrowserSSO(); + const launchedWithTokenURL = await CoreCustomURLSchemes.appLaunchedWithTokenURL(); + if (!launchedWithTokenURL) { + this.openBrowserSSO(); + } } if (CorePlatform.isIOS() && !this.isBrowserSSO) { diff --git a/src/core/services/urlschemes.ts b/src/core/services/urlschemes.ts index fd79c93f9..780739f3e 100644 --- a/src/core/services/urlschemes.ts +++ b/src/core/services/urlschemes.ts @@ -502,6 +502,29 @@ export class CoreCustomURLSchemesProvider { } } + /** + * Get the last URL used to open the app using a URL scheme. + * + * @returns URL. + */ + getLastLaunchURL(): Promise { + return new Promise((resolve) => { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + ( window).plugins.launchmyapp.getLastIntent(intent => resolve(intent), () => resolve(undefined)); + }); + } + + /** + * Check if the last URL used to open the app was a token URL. + * + * @returns Whether was launched with token URL. + */ + async appLaunchedWithTokenURL(): Promise { + const launchUrl = await this.getLastLaunchURL(); + + return !!launchUrl && this.isCustomURLToken(launchUrl); + } + } /**