Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function changeMarketplaceOwner({ userId, permissions }) {
// give global marketplace role to new owner
Roles.setUserRoles(userId, permissions, Roles.GLOBAL_GROUP);
// remove global from previous owner
Meteor.users.update({ _id: Reaction.getUserId() }, { $unset: { [`roles.${Roles.GLOBAL_GROUP}`]: "" } });
}
const _migrateAddress = (address, settings, timestamp) => {
log(`[web3] Migrating address ${address}...`);
const voter = Meteor.users.find({ username: address.toLowerCase() }).fetch();
const template = _getUserObject(address, settings, timestamp);
// add new voter
if (voter.length === 0) {
template.profile = Object.assign(template.profile, settings.profile);
const voterId = Meteor.users.insert(template);
log(`[web3] Inserted new user ${voterId}`);
} else {
log(`[web3] Updated user with new settings.. ${address.toLowerCase()}`);
const newSettings = settings;
let hasCollective = false;
if (voter[0].profile && voter[0].profile.collectives && voter[0].profile.collectives.length > 0) {
for (let k = 0; k < voter[0].profile.collectives.length; k += 1) {
if (voter[0].profile.collectives[k] === voter[0].profile.collectives) {
hasCollective = true;
break;
const MarkerPageContainer = createContainer(({ markerId }) => {
// Subscribe to both marker data + participant names
const subs = Meteor.subscribe('Markers.publications.getMarkerForMarkerPage', markerId);
const marker = Markers.collection.findOne({ _id: markerId });
const markerReady = subs.ready();
// Extend marker object
if (markerReady && marker) {
const { createdBy, participants } = marker;
const author = Meteor.users.findOne({ _id: createdBy });
_.extend(marker, {
createdByName: author.profile.name,
createdByAvatar: author.avatar,
participants: participants.map((participant) => {
const p = Meteor.users.findOne({ _id: participant.userId });
return _.extend(participant, {
userName: p.profile.name,
userAvatar: p.avatar,
});
}),
});
}
return {
urlState: {
markerId,
usersCollection () {
// Return reference to Meteor.users collection
return Meteor.users;
},
userEmail () {
it('unstar', function() {
const conversationIds = [Factory.create('conversation')._id];
Meteor.users.update(userId, {
$set: { 'details.starredConversationIds': conversationIds },
});
unstar._execute({ userId }, { conversationIds });
assert.equal(Meteor.users.findOne(userId).details.starredConversationIds.length, 0);
});
});
module.exports.createSeedData = function({ reset } = {}) {
console.log('createSeedData');
if (reset) {
console.log('reset database...');
resetDatabase();
}
console.log('create users...');
pttUserFactory.buildList(100).forEach((u) => {
Accounts.createUser(u);
});
console.log('make user1 be admin...');
Meteor.users.update({ username: 'user1' }, { $set: { 'profile.roles': 'superAdmin' } });
console.log('create companies...');
companyFactory.buildList(100).forEach((c) => {
dbCompanies.insert(c);
});
console.log('make user1 be the manager of all companies...');
setManagerOfAllCompanies(Meteor.users.find({ username: 'user1' }).fetch()[0]._id);
console.log('randomly allocate stocks...');
randomlyAllocateStocks();
console.log('add companies to archive...');
const companyArchiveBulk = dbCompanyArchive.rawCollection().initializeUnorderedBulkOp();
dbCompanies
.find({ isSeal: false })
function sendAccessRequestEmailTo({
requesterId,
organizationId,
approverId,
source,
message,
}) {
const approver = Meteor.users.findOne(approverId);
const requester = Meteor.users.findOne(requesterId);
const requesterOrganization = Organizations.findOne(organizationId);
const approverOrganization = Organizations.findOne(source.organizationId);
const approverEmailAddress = approver.emails[0].address;
const requesterEmailAddress = requester.emails[0].address;
const requestId = SourceAccessRequests.insert({
organizationId,
sourceId: source._id,
requesterId,
message,
});
const selector = { _id: requestId };
title = `navbar-${params}`;
} else {
const contractTitle = Contracts.findOne({ keyword: params }).title;
if (Meteor.Device.isPhone()) {
return TAPi18n.__('proposal');
}
return `${TAPi18n.__('proposal')} <strong><em>${contractTitle}</em></strong>`;
}
} else {
for (const key in params) {
if (title.length !== 0) { title += '-'; }
switch (key) {
case 'tag':
return `<strong><em>${Tags.findOne({ keyword: params[key] }).text}</em></strong>${TAPi18n.__('proposals')}`;
case 'username': {
const identity = Meteor.users.findOne({ username: params[key] });
if (identity) {
const fullname = showFullName(identity.profile.firstName, identity.profile.lastName, identity.username);
return `${fullname}`;
}
return `${TAPi18n.__('peer')} ${TAPi18n.__('proposals')}`;
}
case 'hash':
case 'query':
break;
default:
if (key !== 'peer') {
title += `${key}-${params[key]}`;
} else {
title += key;
}
}
students() {
return Meteor.users.find({
_id: { $in: this.studentIds }
});
},
const targetUser = Meteor.users.findByIdOrThrow(userId, { fields: { 'profile.ban': 1 } });
const oldBanList = targetUser.profile.ban || [];
const isAlreadyBanned = oldBanList.includes(banType);
const shouldBan = ! isAlreadyBanned;
if (violationCaseId) {
dbViolationCases.findByIdOrThrow(violationCaseId, { fields: { _id: 1 } });
}
if (shouldBan) {
Meteor.users.update(userId, { $addToSet: { 'profile.ban': banType } });
}
else {
Meteor.users.update(userId, { $pull: { 'profile.ban': banType } });
}
const logTypeMap = shouldBan ? {
accuse: '禁止舉報',
deal: '禁止下單',
chat: '禁止聊天',
advertise: '禁止廣告',
editUserAbout: '禁止簡介',
manager: '禁任經理'
} : {
accuse: '解除舉報',
deal: '解除下單',
chat: '解除聊天',
advertise: '解除廣告',
editUserAbout: '解除簡介',
manager: '解除禁任'