]> git.mxchange.org Git - friendica.git/commitdiff
Fix update password rehash
authorAlexandre Alapetite <alexandre@alapetite.fr>
Sun, 8 Apr 2018 10:28:04 +0000 (12:28 +0200)
committerAlexandre Alapetite <alexandre@alapetite.fr>
Sun, 8 Apr 2018 10:40:35 +0000 (12:40 +0200)
Fixes https://github.com/friendica/friendica/issues/4743
The logic for updating password was wrong:
https://github.com/friendica/friendica/commit/b0a764b14c2f2798f7eb223e58d47530f80609c1#diff-1466bb1a0a37fe9f7cf52eda8f3b431aR150

src/Model/User.php

index 4ae43c3e11839ae45cf1505b26f569010f1db076..abf4d1d3e4d2ce8d486fee3d0d2586d83ce62c7a 100644 (file)
@@ -127,18 +127,18 @@ class User
        {
                $user = self::getAuthenticationInfo($user_info);
 
-               if ($user['legacy_password']) {
-                       if (password_verify(self::hashPasswordLegacy($password), $user['password'])) {
-                               self::updatePassword($user['uid'], $password);
-
-                               return $user['uid'];
-                       }
-               } elseif (password_verify($password, $user['password'])) {
+               if (password_verify($password, $user['password'])) {
                        if (password_needs_rehash($user['password'], PASSWORD_DEFAULT)) {
                                self::updatePassword($user['uid'], $password);
                        }
 
                        return $user['uid'];
+               } elseif (!empty($user['legacy_password']) || strpos($user['password'], '$') === false) {
+                       if (self::hashPasswordLegacy($password) === $user['password']) {
+                               self::updatePassword($user['uid'], $password);
+
+                               return $user['uid'];
+                       }
                }
 
                throw new Exception(L10n::t('Login failed'));