From fbf9d6c7fa00427fa80cd232abac5096b33fd37f Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Tue, 18 Jan 2022 12:51:28 +0100 Subject: [PATCH 1/2] MOBILE-3715 login: Show error if SSO login with external app --- scripts/langindex.json | 1 + src/app/app.component.ts | 15 ++++++++++++--- src/core/lang.json | 1 + 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/scripts/langindex.json b/scripts/langindex.json index feedd73b5..a868e07eb 100644 --- a/scripts/langindex.json +++ b/scripts/langindex.json @@ -1658,6 +1658,7 @@ "core.errorsync": "local_moodlemobileapp", "core.errorsyncblocked": "local_moodlemobileapp", "core.errorurlschemeinvalidscheme": "local_moodlemobileapp", + "core.errorurlschemeinvalidschemessologin": "local_moodlemobileapp", "core.errorurlschemeinvalidsite": "local_moodlemobileapp", "core.expand": "moodle", "core.explanationdigitalminor": "moodle", diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 5f2359678..d5aad5141 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -19,7 +19,7 @@ import { BackButtonEvent } from '@ionic/core'; import { CoreLang } from '@services/lang'; import { CoreLoginHelper } from '@features/login/services/login-helper'; import { CoreEvents } from '@singletons/events'; -import { Network, NgZone, Platform, SplashScreen } from '@singletons'; +import { Network, NgZone, Platform, SplashScreen, Translate } from '@singletons'; import { CoreApp, CoreAppProvider } from '@services/app'; import { CoreSites } from '@services/sites'; import { CoreNavigator } from '@services/navigator'; @@ -30,6 +30,7 @@ import { CoreUtils } from '@services/utils/utils'; import { CoreUrlUtils } from '@services/utils/url'; import { CoreConstants } from '@/core/constants'; import { CoreSitePlugins } from '@features/siteplugins/services/siteplugins'; +import { CoreDomUtils } from '@services/utils/dom'; const MOODLE_VERSION_PREFIX = 'version-'; const MOODLEAPP_VERSION_PREFIX = 'moodleapp-'; @@ -111,6 +112,8 @@ export class AppComponent implements OnInit, AfterViewInit { // URLs with a custom scheme can be prefixed with "http://" or "https://", we need to remove this. const protocol = CoreUrlUtils.getUrlProtocol(event.url); const url = event.url.replace(/^https?:\/\//, ''); + const urlScheme = CoreUrlUtils.getUrlProtocol(url); + const isExternalApp = urlScheme && urlScheme !== 'file' && urlScheme !== 'cdvfile'; if (CoreCustomURLSchemes.isCustomURL(url)) { // Close the browser if it's a valid SSO URL. @@ -119,10 +122,16 @@ export class AppComponent implements OnInit, AfterViewInit { }); CoreUtils.closeInAppBrowser(); + } else if (isExternalApp && url.includes('://token=')) { + // It's an SSO token for another app. Close the IAB and show an error. + CoreUtils.closeInAppBrowser(); + CoreDomUtils.showErrorModal(Translate.instant('core.errorurlschemeinvalidschemessologin', { + $a: urlScheme, + })); + } else if (CoreApp.isAndroid()) { // Check if the URL has a custom URL scheme. In Android they need to be opened manually. - const urlScheme = CoreUrlUtils.getUrlProtocol(url); - if (urlScheme && urlScheme !== 'file' && urlScheme !== 'cdvfile') { + if (isExternalApp) { // Open in browser should launch the right app if found and do nothing if not found. CoreUtils.openInBrowser(url, { showBrowserWarning: false }); diff --git a/src/core/lang.json b/src/core/lang.json index 68fa3736d..64fcba1f9 100644 --- a/src/core/lang.json +++ b/src/core/lang.json @@ -113,6 +113,7 @@ "errorsync": "An error occurred while synchronising. Please try again.", "errorsyncblocked": "This {{$a}} cannot be synchronised right now because of an ongoing process. Please try again later. If the problem persists, try restarting the app.", "errorurlschemeinvalidscheme": "This URL is meant to be used in another app: {{$a}}.", + "errorurlschemeinvalidschemessologin": "This site is configured to be used in another app: {{$a}}.", "errorurlschemeinvalidsite": "This site URL cannot be opened in this app.", "expand": "Expand", "explanationdigitalminor": "This information is required to determine if your age is over the digital age of consent. This is the age when an individual can consent to terms and conditions and their data being legally stored and processed.", From 60fa415ee215568ce63a04b7d22fbc148c205787 Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Tue, 18 Jan 2022 14:23:37 +0100 Subject: [PATCH 2/2] MOBILE-3833 lang: Update removed strings in langindex --- scripts/langindex.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/langindex.json b/scripts/langindex.json index a868e07eb..2d2e2f376 100644 --- a/scripts/langindex.json +++ b/scripts/langindex.json @@ -47,7 +47,7 @@ "addon.block_myoverview.inprogress": "block_myoverview", "addon.block_myoverview.lastaccessed": "block_myoverview", "addon.block_myoverview.list": "block_myoverview", - "addon.block_myoverview.nocourses": "block_myoverview", + "addon.block_myoverview.nocourses": "moodle", "addon.block_myoverview.past": "block_myoverview", "addon.block_myoverview.pluginname": "block_myoverview", "addon.block_myoverview.shortname": "block_myoverview", @@ -345,7 +345,7 @@ "addon.mod_assign.cutoffdate": "assign", "addon.mod_assign.defaultteam": "assign", "addon.mod_assign.duedate": "assign", - "addon.mod_assign.duedateno": "assign", + "addon.mod_assign.duedateno": "local_moodlemobileapp", "addon.mod_assign.duedatereached": "assign", "addon.mod_assign.editingstatus": "assign", "addon.mod_assign.editsubmission": "assign", @@ -881,8 +881,8 @@ "addon.mod_quiz.requirepasswordmessage": "quizaccess_password", "addon.mod_quiz.returnattempt": "quiz", "addon.mod_quiz.review": "quiz", - "addon.mod_quiz.reviewofattempt": "quiz", - "addon.mod_quiz.reviewofpreview": "quiz", + "addon.mod_quiz.reviewofattempt": "local_moodlemobileapp", + "addon.mod_quiz.reviewofpreview": "local_moodlemobileapp", "addon.mod_quiz.showall": "quiz", "addon.mod_quiz.showeachpage": "quiz", "addon.mod_quiz.startattempt": "quiz",