core: fix user cache

This commit is contained in:
undefined committed 2023-06-09 16:03:26 +08:00
1 parent 6f6bdee077
commit 1afae60671
1 file changed
+5
+5
View File
@@ -265,6 +265,11 @@ class UserModel {
if ($unset && Object.keys($unset).length) op.$unset = $unset; if ($unset && Object.keys($unset).length) op.$unset = $unset;
if ($push && Object.keys($push).length) op.$push = $push; if ($push && Object.keys($push).length) op.$push = $push;
if (op.$set?.loginip) op.$addToSet = { ip: op.$set.loginip }; if (op.$set?.loginip) op.$addToSet = { ip: op.$set.loginip };
const keys = new Set(Object.values(op).flatMap((i) => Object.keys(i)));
if (keys.has('mailLower') || keys.has('unameLower')) {
const udoc = await coll.findOne({ _id: uid });
deleteUserCache(udoc);
}
const res = await coll.findOneAndUpdate({ _id: uid }, op, { returnDocument: 'after' }); const res = await coll.findOneAndUpdate({ _id: uid }, op, { returnDocument: 'after' });
deleteUserCache(res.value); deleteUserCache(res.value);
return res; return res;