mirror of
https://github.com/wekan/wekan.git
synced 2025-12-17 16:00:13 +01:00
Move every Users.findOne() to the ReactiveCache
This commit is contained in:
parent
bf48d4371c
commit
6e1ef3d94a
35 changed files with 175 additions and 125 deletions
|
|
@ -1,3 +1,5 @@
|
|||
import { ReactiveCache } from '/imports/reactiveCache';
|
||||
|
||||
Org = new Mongo.Collection('org');
|
||||
|
||||
/**
|
||||
|
|
@ -78,10 +80,8 @@ Org.attachSchema(
|
|||
if (Meteor.isServer) {
|
||||
Org.allow({
|
||||
insert(userId, doc) {
|
||||
const user = Users.findOne({
|
||||
_id: userId,
|
||||
});
|
||||
if ((user && user.isAdmin) || (Meteor.user() && Meteor.user().isAdmin))
|
||||
const user = ReactiveCache.getUser(userId) || ReactiveCache.getCurrentUser();
|
||||
if (user?.isAdmin)
|
||||
return true;
|
||||
if (!user) {
|
||||
return false;
|
||||
|
|
@ -89,10 +89,8 @@ if (Meteor.isServer) {
|
|||
return doc._id === userId;
|
||||
},
|
||||
update(userId, doc) {
|
||||
const user = Users.findOne({
|
||||
_id: userId,
|
||||
});
|
||||
if ((user && user.isAdmin) || (Meteor.user() && Meteor.user().isAdmin))
|
||||
const user = ReactiveCache.getUser(userId) || ReactiveCache.getCurrentUser();
|
||||
if (user?.isAdmin)
|
||||
return true;
|
||||
if (!user) {
|
||||
return false;
|
||||
|
|
@ -100,10 +98,8 @@ if (Meteor.isServer) {
|
|||
return doc._id === userId;
|
||||
},
|
||||
remove(userId, doc) {
|
||||
const user = Users.findOne({
|
||||
_id: userId,
|
||||
});
|
||||
if ((user && user.isAdmin) || (Meteor.user() && Meteor.user().isAdmin))
|
||||
const user = ReactiveCache.getUser(userId) || ReactiveCache.getCurrentUser();
|
||||
if (user?.isAdmin)
|
||||
return true;
|
||||
if (!user) {
|
||||
return false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue