mirror of
https://github.com/wekan/wekan.git
synced 2026-11-07 11:02:33 -05:00
22 lines
854 B
JavaScript
22 lines
854 B
JavaScript
import { Meteor } from 'meteor/meteor';
|
|
import { tripCanary } from '/server/lib/canary';
|
|
|
|
// Organization and Team configuration is instance/tenant administration data.
|
|
// Client-side collection mutations are therefore site-admin only; scoped writes
|
|
// run through server methods that enforce their own tenant/admin contract.
|
|
//
|
|
// TenantBleed (GHSA-p4cq-83j9-7g73): Org and Team previously also allowed any
|
|
// authenticated user to mutate a document whose _id equalled their user id.
|
|
// A document id is not an authorization relationship.
|
|
export async function allowSiteAdminCollectionMutation(userId) {
|
|
if (!userId) return false;
|
|
const user = await Meteor.users.findOneAsync(userId, {
|
|
fields: { isAdmin: 1 },
|
|
});
|
|
if (user?.isAdmin) return true;
|
|
if (user) {
|
|
tripCanary('tenant.mutate-without-admin', { userId });
|
|
}
|
|
return false;
|
|
}
|