Skip to content

Commit 68d2ecb

Browse files
authored
Merge pull request #4518 from alfonso-salces/MOBILE-4816
MOBILE-4816 forgotten-password: Beautify invalidparameter error
2 parents 6584918 + 9135d74 commit 68d2ecb

File tree

4 files changed

+20
-1
lines changed

4 files changed

+20
-1
lines changed

scripts/langindex.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2093,6 +2093,7 @@
20932093
"core.imageviewer": "local_moodlemobileapp",
20942094
"core.info": "moodle",
20952095
"core.invalidformdata": "error",
2096+
"core.invalidusername": "error",
20962097
"core.ioscookieshelp": "local_moodlemobileapp",
20972098
"core.labelsep": "langconfig",
20982099
"core.lastaccess": "moodle",

src/core/features/login/pages/forgotten-password/forgotten-password.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import { CoreLoadings } from '@services/overlays/loadings';
2727
import { CoreAlerts } from '@services/overlays/alerts';
2828
import { CoreSharedModule } from '@/core/shared.module';
2929
import { CoreLoginExceededAttemptsComponent } from '../../components/exceeded-attempts/exceeded-attempts';
30+
import { CoreError } from '@classes/errors/error';
3031

3132
/**
3233
* Page to recover a forgotten password.
@@ -125,7 +126,13 @@ export default class CoreLoginForgottenPasswordPage implements OnInit {
125126
await CoreLoginHelper.passwordResetRequested(this.site.getURL());
126127
}
127128
} catch (error) {
128-
CoreAlerts.showError(error);
129+
if (error.errorcode === 'invalidparameter') {
130+
CoreAlerts.showError(new CoreError(
131+
Translate.instant(isMail ? 'core.login.invalidemail' : 'core.invalidusername'),
132+
));
133+
} else {
134+
CoreAlerts.showError(error);
135+
}
129136
} finally {
130137
modal.dismiss();
131138
}

src/core/features/login/tests/behat/basic_usage.feature

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,3 +216,13 @@ Feature: Test basic usage of login in app
216216
When I go back in the app
217217
And I press "Contact support" in the app
218218
Then the app should have opened a browser tab with url ".*\/user\/contactsitesupport\.php"
219+
220+
Scenario: Reset password invalid parameters
221+
When I launch the app
222+
And I set the field "Your site" to "$WWWROOT" in the app
223+
And I press "Connect to your site" in the app
224+
And I press "Lost password?" in the app
225+
Then I set the following fields to these values in the app:
226+
| Enter either username or email address | test#test |
227+
And I press "Search" in the app
228+
And I should find "The given username contains invalid characters" in the app

src/core/lang.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@
165165
"imageviewer": "Image viewer",
166166
"info": "Information",
167167
"invalidformdata": "Incorrect form data",
168+
"invalidusername": "The given username contains invalid characters",
168169
"ioscookieshelp": "Embedded content might require cookies to work. Please go to the app's iOS settings, enable 'Allow Cross-Website Tracking' and try again.",
169170
"labelsep": ":",
170171
"lastaccess": "Last access",

0 commit comments

Comments
 (0)