Move every Users.findOne() to the ReactiveCache

This commit is contained in:
Martin Filser 2023-01-15 01:11:16 +01:00
parent bf48d4371c
commit 6e1ef3d94a
35 changed files with 175 additions and 125 deletions

View file

@ -503,9 +503,7 @@ Users.attachSchema(
Users.allow({
update(userId, doc) {
const user = Users.findOne({
_id: userId,
});
const user = ReactiveCache.getUser(userId);
if ((user && user.isAdmin) || (Meteor.user() && Meteor.user().isAdmin))
return true;
if (!user) {
@ -1445,7 +1443,7 @@ if (Meteor.isServer) {
});
}
Accounts.sendEnrollmentEmail(newUserId);
user = Users.findOne(newUserId);
user = ReactiveCache.getUser(newUserId);
}
board.addMember(user._id);
@ -1949,9 +1947,7 @@ if (Meteor.isServer) {
Users.after.insert((userId, doc) => {
// HACK
doc = Users.findOne({
_id: doc._id,
});
doc = ReactiveCache.getUser(doc._id);
if (doc.createdThroughApi) {
// The admin user should be able to create a user despite disabling registration because
// it is two different things (registration and creation).