diff --git a/src/core/features/login/services/login-helper.ts b/src/core/features/login/services/login-helper.ts
index 22bb66755..7599d2a84 100644
--- a/src/core/features/login/services/login-helper.ts
+++ b/src/core/features/login/services/login-helper.ts
@@ -56,6 +56,7 @@ import {
     IDENTITY_PROVIDER_FEATURE_NAME_PREFIX,
 } from '../constants';
 import { LazyRoutesModule } from '@/app/app-routing.module';
+import { CoreSiteError } from '@classes/errors/siteerror';
 
 /**
  * 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.
      */
-    protected showInvalidLoginModal(error: CoreWSError): void {
-        CoreDomUtils.showErrorModal(error.message);
+    protected showInvalidLoginModal(error: CoreError): void {
+        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 password User password.
      */
-    treatUserTokenError(siteUrl: string, error: CoreWSError, username?: string, password?: string): void {
-        switch (error.errorcode) {
+    treatUserTokenError(siteUrl: string, error: CoreError, username?: string, password?: string): void {
+        const errorCode = 'errorcode' in error ? error.errorcode : null;
+
+        switch (errorCode) {
             case 'forcepasswordchangenotice':
                 this.openChangePassword(siteUrl, CoreTextUtils.getErrorMessageFromError(error) ?? '');
                 break;
diff --git a/src/core/features/login/tests/behat/basic_usage.feature b/src/core/features/login/tests/behat/basic_usage.feature
index 46bc64d17..b0eb396ad 100755
--- a/src/core/features/login/tests/behat/basic_usage.feature
+++ b/src/core/features/login/tests/behat/basic_usage.feature
@@ -47,6 +47,16 @@ Feature: Test basic usage of login in app
     And I press "Connect to your 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
     Given I entered the app as "student1"
     And I press the user menu button in the app