Move every Users.findOne(idOrFirstObjectSelector, options) to the ReactiveCache

This commit is contained in:
Martin Filser 2023-02-04 11:16:53 +01:00
parent 68610e5066
commit 0767f50af8
17 changed files with 43 additions and 33 deletions

View file

@ -21,7 +21,7 @@ Meteor.startup(() => {
error.statusCode = 401;
throw error;
}
const admin = Users.findOne({ _id: userId, isAdmin: true });
const admin = ReactiveCache.getUser({ _id: userId, isAdmin: true });
if (admin === undefined) {
const error = new Meteor.Error('Forbidden', 'Forbidden');
@ -44,7 +44,7 @@ Meteor.startup(() => {
// This throws an error if otherReq is false and the user is not an admin
Authentication.checkAdminOrCondition = function(userId, otherReq) {
if (otherReq) return;
const admin = Users.findOne({ _id: userId, isAdmin: true });
const admin = ReactiveCache.getUser({ _id: userId, isAdmin: true });
if (admin === undefined) {
const error = new Meteor.Error('Forbidden', 'Forbidden');
error.statusCode = 403;