mirror of
https://github.com/wekan/wekan.git
synced 2026-01-28 20:26:09 +01:00
Move every Users.findOne(idOrFirstObjectSelector, options) to the ReactiveCache
This commit is contained in:
parent
68610e5066
commit
0767f50af8
17 changed files with 43 additions and 33 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -334,7 +334,7 @@ function buildSelector(queryParams) {
|
|||
if (queryParams.hasOperator(OPERATOR_USER)) {
|
||||
const users = [];
|
||||
queryParams.getPredicates(OPERATOR_USER).forEach(username => {
|
||||
const user = Users.findOne({ username });
|
||||
const user = ReactiveCache.getUser({ username });
|
||||
if (user) {
|
||||
users.push(user._id);
|
||||
} else {
|
||||
|
|
@ -352,7 +352,7 @@ function buildSelector(queryParams) {
|
|||
if (queryParams.hasOperator(key)) {
|
||||
const users = [];
|
||||
queryParams.getPredicates(key).forEach(username => {
|
||||
const user = Users.findOne({ username });
|
||||
const user = ReactiveCache.getUser({ username });
|
||||
if (user) {
|
||||
users.push(user._id);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -260,7 +260,7 @@ RulesHelper = {
|
|||
card.removeLabel(action.labelId);
|
||||
}
|
||||
if (action.actionType === 'addMember') {
|
||||
const memberId = Users.findOne({ username: action.username })._id;
|
||||
const memberId = ReactiveCache.getUser({ username: action.username })._id;
|
||||
card.assignMember(memberId);
|
||||
}
|
||||
if (action.actionType === 'removeMember') {
|
||||
|
|
@ -270,7 +270,7 @@ RulesHelper = {
|
|||
card.unassignMember(members[i]);
|
||||
}
|
||||
} else {
|
||||
const memberId = Users.findOne({ username: action.username })._id;
|
||||
const memberId = ReactiveCache.getUser({ username: action.username })._id;
|
||||
card.unassignMember(memberId);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue