优化csrf_token检查

This commit is contained in:
undefined committed 2020-07-04 22:49:02 +08:00
1 parent fb5c29226b
commit c9b6412527
10 files changed
+77 -185

No files matched your search

+7 -7
View File
@@ -73,13 +73,13 @@ function getMulti(domainId, query) {
async function update(domainId, rid, $set, $push, $unset) {
const _id = new ObjectID(rid);
const upd = {};
if ($set && Object.keys($set).length) upd.$set = $set;
if ($push && Object.keys($push).length) upd.$push = $push;
if ($unset && Object.keys($unset).length) upd.$unset = $unset;
const rdoc = await coll.findOneAndUpdate({ domainId, _id }, upd, { returnOriginal: false });
if (!rdoc) throw new RecordNotFoundError(rid);
return rdoc;
const $update = {};
if ($set && Object.keys($set).length) $update.$set = $set;
if ($push && Object.keys($push).length) $update.$push = $push;
if ($unset && Object.keys($unset).length) $update.$unset = $unset;
const res = await coll.findOneAndUpdate({ domainId, _id }, $update, { returnOriginal: false });
if (!res.value) throw new RecordNotFoundError(rid);
return res.value;
}
function reset(domainId, rid) {