fix: reject stale company profile and filter updates
This commit is contained in:
+7
-4
@@ -1194,7 +1194,7 @@ const server = http.createServer(async (req, res) => {
|
||||
|
||||
if (req.method === 'GET') {
|
||||
if (anahtar) return json(res, 200, { success: true, anahtar, deger: store.getData(user.email, anahtar) });
|
||||
return json(res, 200, { success: true, veri: store.getAllData(user.email) });
|
||||
return json(res, 200, { success: true, ...store.getDataSnapshot(user.email) });
|
||||
}
|
||||
if (req.method === 'PUT' || req.method === 'POST') {
|
||||
try {
|
||||
@@ -1205,10 +1205,13 @@ const server = http.createServer(async (req, res) => {
|
||||
if (k === 'ekip' && Array.isArray(body.deger)) {
|
||||
kotaKontrol(user.email, 'ekip', 0, body.deger.length, { isAdmin: user.isAdmin });
|
||||
}
|
||||
store.setData(user.email, k, body.deger);
|
||||
return json(res, 200, { success: true });
|
||||
const protectedKey=['firma_profil','saved_filters'].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);
|
||||
return json(res, 200, { success: true, ...(protectedKey ? {revision} : {}) });
|
||||
} catch (e) {
|
||||
return json(res, e.kod === 'KOTA_ASILDI' ? 402 : 400, { success: false, error: e.message, kod: e.kod || null });
|
||||
return json(res, e.kod === 'KOTA_ASILDI' ? 402 : e.kod === 'VERSION_CONFLICT' ? 409 : 400, { success: false, error: e.message, kod: e.kod || null });
|
||||
}
|
||||
}
|
||||
return json(res, 405, { success: false, error: 'desteklenmeyen metot' });
|
||||
|
||||
Reference in New Issue
Block a user