From 8d1a27ee8d9fd9f86e5bc7f7d381dc64188b0505 Mon Sep 17 00:00:00 2001 From: Alfonso Salces Date: Mon, 28 Jul 2025 13:44:37 +0200 Subject: [PATCH 1/2] MOBILE-4816 forgotten-password: Beautify invalidparameter error --- scripts/langindex.json | 1 + .../login/pages/forgotten-password/forgotten-password.ts | 9 ++++++++- src/core/lang.json | 1 + 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/scripts/langindex.json b/scripts/langindex.json index 6a0b34047cb..f82c4c7c947 100644 --- a/scripts/langindex.json +++ b/scripts/langindex.json @@ -2093,6 +2093,7 @@ "core.imageviewer": "local_moodlemobileapp", "core.info": "moodle", "core.invalidformdata": "error", + "core.invalidusername": "error", "core.ioscookieshelp": "local_moodlemobileapp", "core.labelsep": "langconfig", "core.lastaccess": "moodle", diff --git a/src/core/features/login/pages/forgotten-password/forgotten-password.ts b/src/core/features/login/pages/forgotten-password/forgotten-password.ts index d93736c9939..35709cf2b5d 100644 --- a/src/core/features/login/pages/forgotten-password/forgotten-password.ts +++ b/src/core/features/login/pages/forgotten-password/forgotten-password.ts @@ -27,6 +27,7 @@ import { CoreLoadings } from '@services/overlays/loadings'; import { CoreAlerts } from '@services/overlays/alerts'; import { CoreSharedModule } from '@/core/shared.module'; import { CoreLoginExceededAttemptsComponent } from '../../components/exceeded-attempts/exceeded-attempts'; +import { CoreError } from '@classes/errors/error'; /** * Page to recover a forgotten password. @@ -125,7 +126,13 @@ export default class CoreLoginForgottenPasswordPage implements OnInit { await CoreLoginHelper.passwordResetRequested(this.site.getURL()); } } catch (error) { - CoreAlerts.showError(error); + if (error.errorcode === 'invalidparameter') { + CoreAlerts.showError(new CoreError( + Translate.instant(isMail ? 'core.login.invalidemail' : 'core.invalidusername'), + )); + } else { + CoreAlerts.showError(error); + } } finally { modal.dismiss(); } diff --git a/src/core/lang.json b/src/core/lang.json index 7d374126ed2..b51660afd0f 100644 --- a/src/core/lang.json +++ b/src/core/lang.json @@ -165,6 +165,7 @@ "imageviewer": "Image viewer", "info": "Information", "invalidformdata": "Incorrect form data", + "invalidusername": "The given username contains invalid characters", "ioscookieshelp": "Embedded content might require cookies to work. Please go to the app's iOS settings, enable 'Allow Cross-Website Tracking' and try again.", "labelsep": ":", "lastaccess": "Last access", From 9135d7427ef7d7e2156659bf61c978b32384015b Mon Sep 17 00:00:00 2001 From: Alfonso Salces Date: Tue, 29 Jul 2025 11:19:32 +0200 Subject: [PATCH 2/2] MOBILE-4816 tests: Add forgotten password behat tests --- .../features/login/tests/behat/basic_usage.feature | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/core/features/login/tests/behat/basic_usage.feature b/src/core/features/login/tests/behat/basic_usage.feature index 3c73422bcca..ca3c635ba28 100755 --- a/src/core/features/login/tests/behat/basic_usage.feature +++ b/src/core/features/login/tests/behat/basic_usage.feature @@ -216,3 +216,13 @@ Feature: Test basic usage of login in app When I go back in the app And I press "Contact support" in the app Then the app should have opened a browser tab with url ".*\/user\/contactsitesupport\.php" + + Scenario: Reset password invalid parameters + When I launch the app + And I set the field "Your site" to "$WWWROOT" in the app + And I press "Connect to your site" in the app + And I press "Lost password?" in the app + Then I set the following fields to these values in the app: + | Enter either username or email address | test#test | + And I press "Search" in the app + And I should find "The given username contains invalid characters" in the app