mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: fix user cache
This commit is contained in:
1 file changed
+5
@@ -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;
|
||||||
|
|||||||
Reference in new issue
Block a user