Skip to content

Commit

Permalink
MOBILE-4201 login: Remove SSO open browser confirmation
Browse files Browse the repository at this point in the history
  • Loading branch information
crazyserver committed Sep 7, 2023
1 parent 8f14be5 commit 7f99c77
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 40 deletions.
1 change: 0 additions & 1 deletion moodle.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@
"multisitesdisplay": "",
"sitefindersettings": {},
"onlyallowlistedsites": false,
"skipssoconfirmation": false,
"forcedefaultlanguage": false,
"privacypolicy": "https://moodle.net/moodle-app-privacy/",
"notificoncolor": "#f98012",
Expand Down
1 change: 0 additions & 1 deletion scripts/langindex.json
Original file line number Diff line number Diff line change
Expand Up @@ -2087,7 +2087,6 @@
"core.login.invalidvaluemin": "local_moodlemobileapp",
"core.login.login": "moodle",
"core.login.loginbutton": "local_moodlemobileapp",
"core.login.logininsiterequired": "local_moodlemobileapp",
"core.login.loginsteps": "moodle",
"core.login.missingemail": "moodle",
"core.login.missingfirstname": "moodle",
Expand Down
1 change: 0 additions & 1 deletion src/core/features/login/lang.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@
"invalidvaluemin": "The minimum value is {{$a}}",
"login": "Log in",
"loginbutton": "Log in",
"logininsiterequired": "You need to log in to the site in a browser window.",
"loginsteps": "For full access to this site, you first need to create an account.",
"missingemail": "Missing email address",
"missingfirstname": "Missing given name",
Expand Down
2 changes: 1 addition & 1 deletion src/core/features/login/pages/credentials/credentials.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ export class CoreLoginCredentialsPage implements OnInit, OnDestroy {
return;
}

CoreLoginHelper.confirmAndOpenBrowserForSSOLogin(
CoreLoginHelper.openBrowserForSSOLogin(
this.siteCheck.siteUrl,
this.siteCheck.code,
this.siteCheck.service,
Expand Down
2 changes: 1 addition & 1 deletion src/core/features/login/pages/reconnect/reconnect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ export class CoreLoginReconnectPage implements OnInit, OnDestroy {
return;
}

CoreLoginHelper.confirmAndOpenBrowserForSSOLogin(
CoreLoginHelper.openBrowserForSSOLogin(
this.siteUrl,
this.siteConfig.typeoflogin,
undefined,
Expand Down
20 changes: 5 additions & 15 deletions src/core/features/login/services/login-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,15 @@ export class CoreLoginHelperProvider {
}

/**
* Show a confirm modal if needed and open a browser to perform SSO login.
* Open a browser to perform SSO login.
*
* @param siteUrl URL of the site where the SSO login will be performed.
* @param typeOfLogin CoreConstants.LOGIN_SSO_CODE or CoreConstants.LOGIN_SSO_INAPP_CODE.
* @param service The service to use. If not defined, core service will be used.
* @param launchUrl The URL to open for SSO. If not defined, default tool mobile launch URL will be used.
* @param redirectData Data of the path/url to open once authenticated. If not defined, site initial page.
* @returns Promise resolved when done or if user cancelled.
* @deprecated since 4.3. Use openBrowserForSSOLogin instead.
*/
async confirmAndOpenBrowserForSSOLogin(
siteUrl: string,
Expand All @@ -157,18 +158,6 @@ export class CoreLoginHelperProvider {
launchUrl?: string,
redirectData?: CoreRedirectPayload,
): Promise<void> {
// Show confirm only if it's needed. Treat "false" (string) as false to prevent typing errors.
const showConfirmation = this.shouldShowSSOConfirm(typeOfLogin);

if (showConfirmation) {
try {
await CoreDomUtils.showConfirm(Translate.instant('core.login.logininsiterequired'));
} catch {
// User canceled, stop.
return;
}
}

this.openBrowserForSSOLogin(siteUrl, typeOfLogin, service, launchUrl, redirectData);
}

Expand Down Expand Up @@ -978,10 +967,11 @@ export class CoreLoginHelperProvider {
*
* @param typeOfLogin CoreConstants.LOGIN_SSO_CODE or CoreConstants.LOGIN_SSO_INAPP_CODE.
* @returns True if confirm modal should be shown, false otherwise.
* @deprecated since 4.3 Not used anymore.
*/
// eslint-disable-next-line @typescript-eslint/no-unused-vars
shouldShowSSOConfirm(typeOfLogin: number): boolean {
return !this.isSSOEmbeddedBrowser(typeOfLogin) &&
(!CoreConstants.CONFIG.skipssoconfirmation || String(CoreConstants.CONFIG.skipssoconfirmation) === 'false');
return false;
}

/**
Expand Down
26 changes: 7 additions & 19 deletions src/core/services/urlschemes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,6 @@ export class CoreCustomURLSchemesProvider {
* @returns Promise resolved when done.
*/
protected async goToAddSite(data: CoreCustomURLSchemesParams, checkResponse: CoreSiteCheckResponse): Promise<void> {
const ssoNeeded = CoreLoginHelper.isSSOLoginNeeded(checkResponse.code);
const pageParams = {
siteUrl: checkResponse.siteUrl,
username: data.username,
Expand All @@ -402,28 +401,17 @@ export class CoreCustomURLSchemesProvider {
// Ask the user before changing site.
await CoreDomUtils.showConfirm(Translate.instant('core.contentlinks.confirmurlothersite'));

if (!ssoNeeded) {
const willReload = await CoreSites.logoutForRedirect(CoreConstants.NO_SITE_ID, {
redirectPath: '/login/credentials',
redirectOptions: { params: pageParams },
});
const willReload = await CoreSites.logoutForRedirect(CoreConstants.NO_SITE_ID, {
redirectPath: '/login/credentials',
redirectOptions: { params: pageParams },
});

if (willReload) {
return;
}
if (willReload) {
return;
}
}

if (ssoNeeded) {
CoreLoginHelper.confirmAndOpenBrowserForSSOLogin(
checkResponse.siteUrl,
checkResponse.code,
checkResponse.service,
checkResponse.config?.launchurl,
);
} else {
await CoreNavigator.navigateToLoginCredentials(pageParams);
}
await CoreNavigator.navigateToLoginCredentials(pageParams);
}

/**
Expand Down
1 change: 0 additions & 1 deletion src/types/config.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ export interface EnvironmentConfig {
multisitesdisplay: CoreLoginSiteSelectorListMethod;
sitefindersettings: Partial<CoreLoginSiteFinderSettings>;
onlyallowlistedsites: boolean;
skipssoconfirmation: boolean;
forcedefaultlanguage: boolean;
privacypolicy: string;
notificoncolor: string;
Expand Down

0 comments on commit 7f99c77

Please sign in to comment.