fix: persist team changes only after versioned server confirmation

This commit is contained in:
2026-09-06 14:01:28 +03:00
parent 79654d66f7
commit 3d9aa79624
8 changed files with 80 additions and 20 deletions
+4 -2
View File
@@ -1,3 +1,4 @@
import {validateTeam} from '../src/services/teamData.js';
import { executeAnalysisJob } from './analysis-job.mjs';
import { resolveAiJobInput } from './ai-job-source.mjs';
import * as aiJobs from './ai-job-store.mjs';
@@ -1202,10 +1203,11 @@ const server = http.createServer(async (req, res) => {
const k = body.anahtar || anahtar;
if (!k) return json(res, 400, { success: false, error: 'anahtar gerekli' });
// Ekip kotası sunucu tarafında uygulanır
if (k === 'ekip' && Array.isArray(body.deger)) {
if (k === 'ekip') {
validateTeam(body.deger);
kotaKontrol(user.email, 'ekip', 0, body.deger.length, { isAdmin: user.isAdmin });
}
const protectedKey=['firma_profil','saved_filters'].includes(k);
const protectedKey=['firma_profil','saved_filters','ekip'].includes(k);
if(protectedKey && (!Object.hasOwn(body,'revision') || (body.revision!==null && (typeof body.revision!=='string' || !/^[a-f0-9]{64}$/.test(body.revision)))))
return json(res,428,{success:false,kod:'VERSION_REQUIRED',error:'Güncel kayıt sürümü gerekli. Sayfayı yenileyip tekrar deneyin.'});
const revision=store.setData(user.email, k, body.deger, protectedKey ? body.revision : undefined);