MOBILE-4572 login: Don't auto launch SSO if app launched with token URL

main
Dani Palou 2024-04-10 16:05:20 +02:00
parent 7142177e47
commit a54d8e7b64
2 changed files with 28 additions and 1 deletions

View File

@ -34,6 +34,7 @@ import { SafeHtml } from '@angular/platform-browser';
import { CorePlatform } from '@services/platform'; import { CorePlatform } from '@services/platform';
import { CoreSitesFactory } from '@services/sites-factory'; import { CoreSitesFactory } from '@services/sites-factory';
import { EMAIL_SIGNUP_FEATURE_NAME, FORGOTTEN_PASSWORD_FEATURE_NAME } from '@features/login/constants'; import { EMAIL_SIGNUP_FEATURE_NAME, FORGOTTEN_PASSWORD_FEATURE_NAME } from '@features/login/constants';
import { CoreCustomURLSchemes } from '@services/urlschemes';
/** /**
* Page to enter the user credentials. * Page to enter the user credentials.
@ -107,7 +108,10 @@ export class CoreLoginCredentialsPage implements OnInit, OnDestroy {
await this.checkSite(); await this.checkSite();
if (this.isBrowserSSO && CoreLoginHelper.shouldSkipCredentialsScreenOnSSO()) { if (this.isBrowserSSO && CoreLoginHelper.shouldSkipCredentialsScreenOnSSO()) {
this.openBrowserSSO(); const launchedWithTokenURL = await CoreCustomURLSchemes.appLaunchedWithTokenURL();
if (!launchedWithTokenURL) {
this.openBrowserSSO();
}
} }
if (CorePlatform.isIOS() && !this.isBrowserSSO) { if (CorePlatform.isIOS() && !this.isBrowserSSO) {

View File

@ -502,6 +502,29 @@ export class CoreCustomURLSchemesProvider {
} }
} }
/**
* Get the last URL used to open the app using a URL scheme.
*
* @returns URL.
*/
getLastLaunchURL(): Promise<string | undefined> {
return new Promise((resolve) => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(<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<boolean> {
const launchUrl = await this.getLastLaunchURL();
return !!launchUrl && this.isCustomURLToken(launchUrl);
}
} }
/** /**