Frederik Bosch il y a 10 ans
Parent
commit
951b07eabc
1 fichiers modifiés avec 16 ajouts et 2 suppressions
  1. 16 2
      src/Composer/Util/Git.php

+ 16 - 2
src/Composer/Util/Git.php

@@ -106,8 +106,7 @@ class Git
                     }
                 }
             } elseif ( // private non-github repo that failed to authenticate
-                preg_match('{(https?://)([^/]+)(.*)$}i', $url, $match) &&
-                strpos($this->process->getErrorOutput(), 'fatal: Authentication failed') !== false
+                $this->isAuthenticationFailure($url, $match)
             ) {
                 if (strpos($match[2], '@')) {
                     list($authParts, $match[2]) = explode('@', $match[2], 2);
@@ -155,6 +154,21 @@ class Git
         }
     }
 
+    private function isAuthenticationFailure ($url, &$match) {
+        if (!preg_match('{(https?://)([^/]+)(.*)$}i', $url, $match)) {
+            return false;
+        }
+
+        $authFailures = array('fatal: Authentication failed', 'remote error: Invalid username or password.');
+        foreach ($authFailures as $authFailure) {
+            if (strpos($this->process->getErrorOutput(), $authFailure) !== false) {
+                return true;
+            }
+        }
+
+        return false;
+    }
+
     public static function cleanEnv()
     {
         if (ini_get('safe_mode') && false === strpos(ini_get('safe_mode_allowed_env_vars'), 'GIT_ASKPASS')) {