diff --git a/modules/core/lib/Auth/UserPassBase.php b/modules/core/lib/Auth/UserPassBase.php
index 3c0d05266f8b4249eb0cf4d8bc52baa0aa28b6ff..d2cc4dadace396785cbbd911e1aecce4542e015a 100644
--- a/modules/core/lib/Auth/UserPassBase.php
+++ b/modules/core/lib/Auth/UserPassBase.php
@@ -139,18 +139,7 @@ abstract class sspmod_core_Auth_UserPassBase extends SimpleSAML_Auth_Source {
 			/* Attempt to log in. */
 			$attributes = $source->login($username, $password);
 		} catch (SimpleSAML_Error_Error $e) {
-			/* An error occured during login. Check if it is because of the wrong
-			 * username/password - if it is, we pass that error up to the login form,
-			 * if not, we let the generic error handler deal with it.
-			 */
-			if ($e->getErrorCode() === 'WRONGUSERPASS') {
-				return 'WRONGUSERPASS';
-			}
-
-			/* Some other error occured. Rethrow exception and let the generic error
-			 * handler deal with it.
-			 */
-			throw $e;
+			return $e->getErrorCode();
 		}
 
 		$state['Attributes'] = $attributes;
diff --git a/modules/core/lib/Auth/UserPassOrgBase.php b/modules/core/lib/Auth/UserPassOrgBase.php
index 9f1d47bff67ff3618f1e9b2bc0ac72ada00d2cdb..6583d34e1466762306cbbbe8f8f2f7e847729308 100644
--- a/modules/core/lib/Auth/UserPassOrgBase.php
+++ b/modules/core/lib/Auth/UserPassOrgBase.php
@@ -191,18 +191,7 @@ abstract class sspmod_core_Auth_UserPassOrgBase extends SimpleSAML_Auth_Source {
 			/* Attempt to log in. */
 			$attributes = $source->login($username, $password, $organization);
 		} catch (SimpleSAML_Error_Error $e) {
-			/* An error occured during login. Check if it is because of the wrong
-			 * username/password - if it is, we pass that error up to the login form,
-			 * if not, we let the generic error handler deal with it.
-			 */
-			if ($e->getErrorCode() === 'WRONGUSERPASS') {
-				return 'WRONGUSERPASS';
-			}
-
-			/* Some other error occured. Rethrow exception and let the generic error
-			 * handler deal with it.
-			 */
-			throw $e;
+			return $e->getErrorCode();
 		}
 
 		$state['Attributes'] = $attributes;