password; if (! str_starts_with($stored, self::LEGACY_PREFIX)) { return Hash::check($password, $stored); } if (! preg_match('/^acsrp1:([A-Z0-9]{3,16}):([A-F0-9]{64}):([A-F0-9]{64})$/D', $stored, $parts) || ! $this->srp->credentialsMatch($parts[1], $password, $parts[2], $parts[3])) { return false; } // Upgrade only the credential we just verified. A concurrent password // change must not be overwritten or authenticate the old password. $updated = DB::connection($user->getConnectionName())->table('users') ->where('id', $user->id)->where('password', $stored) ->update(['password' => Hash::make($password), 'updated_at' => now()]); if ($updated > 0) { return true; } $fresh = $user->fresh(); return $fresh !== null && ! str_starts_with((string) $fresh->password, self::LEGACY_PREFIX) && Hash::check($password, $fresh->password); } }