MOBILE-4485 login: Fix invalid login message

This commit is contained in:
Noel De Martin 2024-04-04 11:32:22 +02:00
parent fb1600aa66
commit 35cda384b0
2 changed files with 19 additions and 4 deletions

View File

@ -56,6 +56,7 @@ import {
IDENTITY_PROVIDER_FEATURE_NAME_PREFIX, IDENTITY_PROVIDER_FEATURE_NAME_PREFIX,
} from '../constants'; } from '../constants';
import { LazyRoutesModule } from '@/app/app-routing.module'; import { LazyRoutesModule } from '@/app/app-routing.module';
import { CoreSiteError } from '@classes/errors/siteerror';
/** /**
* Helper provider that provides some common features regarding authentication. * Helper provider that provides some common features regarding authentication.
@ -933,8 +934,10 @@ export class CoreLoginHelperProvider {
/** /**
* Show a modal warning that the credentials introduced were not correct. * Show a modal warning that the credentials introduced were not correct.
*/ */
protected showInvalidLoginModal(error: CoreWSError): void { protected showInvalidLoginModal(error: CoreError): void {
CoreDomUtils.showErrorModal(error.message); const errorDetails = error instanceof CoreSiteError ? error.debug?.details : null;
CoreDomUtils.showErrorModal(errorDetails ?? error.message);
} }
/** /**
@ -1074,8 +1077,10 @@ export class CoreLoginHelperProvider {
* @param username Username. * @param username Username.
* @param password User password. * @param password User password.
*/ */
treatUserTokenError(siteUrl: string, error: CoreWSError, username?: string, password?: string): void { treatUserTokenError(siteUrl: string, error: CoreError, username?: string, password?: string): void {
switch (error.errorcode) { const errorCode = 'errorcode' in error ? error.errorcode : null;
switch (errorCode) {
case 'forcepasswordchangenotice': case 'forcepasswordchangenotice':
this.openChangePassword(siteUrl, CoreTextUtils.getErrorMessageFromError(error) ?? ''); this.openChangePassword(siteUrl, CoreTextUtils.getErrorMessageFromError(error) ?? '');
break; break;

View File

@ -47,6 +47,16 @@ Feature: Test basic usage of login in app
And I press "Connect to your site" in the app And I press "Connect to your site" in the app
Then I should find "Can't connect to site" in the app Then I should find "Can't connect to site" in the app
Scenario: Attempt invalid login
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 set the following fields to these values in the app:
| Username | student1 |
| Password | wrongpassword |
And I press "Log in" near "Lost password?" in the app
Then I should find "Invalid login" in the app
Scenario: Add a non existing account from accounts switcher Scenario: Add a non existing account from accounts switcher
Given I entered the app as "student1" Given I entered the app as "student1"
And I press the user menu button in the app And I press the user menu button in the app