mirror of
https://github.com/wekan/wekan.git
synced 2025-09-22 01:50:48 +02:00
Move every ImpersonatedUsers.findOne(idOrFirstObjectSelector, options) to the ReactiveCache
This commit is contained in:
parent
e30edce73e
commit
767d8e66e7
5 changed files with 56 additions and 18 deletions
|
@ -139,6 +139,14 @@ ReactiveCacheServer = {
|
|||
const ret = Triggers.find(selector, options).fetch();
|
||||
return ret;
|
||||
},
|
||||
getImpersonatedUser(idOrFirstObjectSelector, options) {
|
||||
const ret = ImpersonatedUsers.findOne(idOrFirstObjectSelector, options);
|
||||
return ret;
|
||||
},
|
||||
getImpersonatedUsers(selector, options) {
|
||||
const ret = ImpersonatedUsers.find(selector, options).fetch();
|
||||
return ret;
|
||||
},
|
||||
getCurrentSetting() {
|
||||
const ret = Settings.findOne();
|
||||
return ret;
|
||||
|
@ -561,6 +569,30 @@ ReactiveCacheClient = {
|
|||
const ret = this.__triggers.get(Jsons.stringify(select));
|
||||
return ret;
|
||||
},
|
||||
getImpersonatedUser(idOrFirstObjectSelector, options) {
|
||||
const idOrFirstObjectSelect = {idOrFirstObjectSelector, options}
|
||||
if (!this.__impersonatedUser) {
|
||||
this.__impersonatedUser = new DataCache(_idOrFirstObjectSelect => {
|
||||
const __select = Jsons.parse(_idOrFirstObjectSelect);
|
||||
const _ret = ImpersonatedUsers.findOne(__select.idOrFirstObjectSelector, __select.options);
|
||||
return _ret;
|
||||
});
|
||||
}
|
||||
const ret = this.__impersonatedUser.get(Jsons.stringify(idOrFirstObjectSelect));
|
||||
return ret;
|
||||
},
|
||||
getImpersonatedUsers(selector, options) {
|
||||
const select = {selector, options}
|
||||
if (!this.__impersonatedUsers) {
|
||||
this.__impersonatedUsers = new DataCache(_select => {
|
||||
const __select = Jsons.parse(_select);
|
||||
const _ret = ImpersonatedUsers.find(__select.selector, __select.options).fetch();
|
||||
return _ret;
|
||||
});
|
||||
}
|
||||
const ret = this.__impersonatedUsers.get(Jsons.stringify(select));
|
||||
return ret;
|
||||
},
|
||||
getCurrentSetting() {
|
||||
if (!this.__currentSetting || !this.__currentSetting.get()) {
|
||||
this.__currentSetting = new DataCache(() => {
|
||||
|
@ -896,6 +928,24 @@ ReactiveCache = {
|
|||
}
|
||||
return ret;
|
||||
},
|
||||
getImpersonatedUser(idOrFirstObjectSelector, options) {
|
||||
let ret;
|
||||
if (Meteor.isServer) {
|
||||
ret = ReactiveCacheServer.getImpersonatedUser(idOrFirstObjectSelector, options);
|
||||
} else {
|
||||
ret = ReactiveCacheClient.getImpersonatedUser(idOrFirstObjectSelector, options);
|
||||
}
|
||||
return ret;
|
||||
},
|
||||
getImpersonatedUsers(selector, options) {
|
||||
let ret;
|
||||
if (Meteor.isServer) {
|
||||
ret = ReactiveCacheServer.getImpersonatedUsers(selector, options);
|
||||
} else {
|
||||
ret = ReactiveCacheClient.getImpersonatedUsers(selector, options);
|
||||
}
|
||||
return ret;
|
||||
},
|
||||
getCurrentSetting() {
|
||||
let ret;
|
||||
if (Meteor.isServer) {
|
||||
|
|
|
@ -39,9 +39,7 @@ if (Meteor.isServer) {
|
|||
'services.resume.loginTokens.hashedToken': hashToken,
|
||||
});
|
||||
adminId = user._id.toString();
|
||||
impersonateDone = ImpersonatedUsers.findOne({
|
||||
adminId: adminId,
|
||||
});
|
||||
impersonateDone = ReactiveCache.getImpersonatedUser({ adminId: adminId });
|
||||
} else if (!Meteor.settings.public.sandstorm) {
|
||||
Authentication.checkUserId(req.userId);
|
||||
user = ReactiveCache.getUser({ _id: req.userId, isAdmin: true });
|
||||
|
@ -103,9 +101,7 @@ if (Meteor.isServer) {
|
|||
'services.resume.loginTokens.hashedToken': hashToken,
|
||||
});
|
||||
adminId = user._id.toString();
|
||||
impersonateDone = ImpersonatedUsers.findOne({
|
||||
adminId: adminId,
|
||||
});
|
||||
impersonateDone = ReactiveCache.getImpersonatedUser({ adminId: adminId });
|
||||
} else if (!Meteor.settings.public.sandstorm) {
|
||||
Authentication.checkUserId(req.userId);
|
||||
user = ReactiveCache.getUser({ _id: req.userId, isAdmin: true });
|
||||
|
@ -159,9 +155,7 @@ if (Meteor.isServer) {
|
|||
'services.resume.loginTokens.hashedToken': hashToken,
|
||||
});
|
||||
adminId = user._id.toString();
|
||||
impersonateDone = ImpersonatedUsers.findOne({
|
||||
adminId: adminId,
|
||||
});
|
||||
impersonateDone = ReactiveCache.getImpersonatedUser({ adminId: adminId });
|
||||
} else if (!Meteor.settings.public.sandstorm) {
|
||||
Authentication.checkUserId(req.userId);
|
||||
user = ReactiveCache.getUser({
|
||||
|
|
|
@ -42,9 +42,7 @@ runOnServer(function() {
|
|||
'services.resume.loginTokens.hashedToken': hashToken,
|
||||
});
|
||||
adminId = user._id.toString();
|
||||
impersonateDone = ImpersonatedUsers.findOne({
|
||||
adminId: adminId,
|
||||
});
|
||||
impersonateDone = ReactiveCache.getImpersonatedUser({ adminId: adminId });
|
||||
} else if (!Meteor.settings.public.sandstorm) {
|
||||
Authentication.checkUserId(req.userId);
|
||||
user = ReactiveCache.getUser({
|
||||
|
|
|
@ -44,9 +44,7 @@ runOnServer(function() {
|
|||
'services.resume.loginTokens.hashedToken': hashToken,
|
||||
});
|
||||
adminId = user._id.toString();
|
||||
impersonateDone = ImpersonatedUsers.findOne({
|
||||
adminId: adminId,
|
||||
});
|
||||
impersonateDone = ReactiveCache.getImpersonatedUser({ adminId: adminId });
|
||||
} else if (!Meteor.settings.public.sandstorm) {
|
||||
Authentication.checkUserId(req.userId);
|
||||
user = ReactiveCache.getUser({
|
||||
|
|
|
@ -1532,9 +1532,7 @@ if (Meteor.isServer) {
|
|||
},
|
||||
isImpersonated(userId) {
|
||||
check(userId, String);
|
||||
const isImpersonated = ImpersonatedUsers.findOne({
|
||||
userId: userId,
|
||||
});
|
||||
const isImpersonated = ReactiveCache.getImpersonatedUser({ userId: userId });
|
||||
return isImpersonated;
|
||||
},
|
||||
setUsersTeamsTeamDisplayName(teamId, teamDisplayName) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue