Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const trackLogins = function trackLogins() {
// Don't run on first time. We need to access Meteor.userId() for reactivity.
Meteor.userId();
if (initialized) {
// When Meteor.userId() changes this will run.
if (Meteor.userId()) {
// TODO I think it's not guaranteed that userEmail has been set because
// the 'AnalyticsUsers' publication might not be ready yet.
identifyWhenReady(Meteor.userId(), { email: getUserEmail() });
trackEventWhenReady("Signed in");
} else {
trackEventWhenReady("Signed out");
}
}
initialized = true;
};
const me = Meteor.user();
if (!me.username) {
throw new Meteor.Error('error-invalid-user', 'Invalid user', {
method: 'createDirectMessage',
});
}
if (settings.get('Message_AllowDirectMessagesToYourself') === false && me.username === username) {
throw new Meteor.Error('error-invalid-user', 'Invalid user', {
method: 'createDirectMessage',
});
}
if (!hasPermission(Meteor.userId(), 'create-d')) {
throw new Meteor.Error('error-not-allowed', 'Not allowed', {
method: 'createDirectMessage',
});
}
const to = Users.findOneByUsername(username);
if (!to) {
throw new Meteor.Error('error-invalid-user', 'Invalid user', {
method: 'createDirectMessage',
});
}
if (!hasPermission(to._id, 'view-d-room')) {
throw new Meteor.Error('error-not-allowed', 'Target user not allowed to receive messages', {
method: 'createDirectMessage',
newEmailArray.forEach((address) => {
Accounts.addEmail(Meteor.userId(), address);
});
//
newAuction: (name, description, options) => {
check(name, String)
check(description, String)
check(options, Object)
if (Meteor.userId()) {
let user = UserData.findOne({
_id: Meteor.userId()
})
if (options.amount && user && (options.baseCurrency === 'KZR' ? user.balance : (user.others || {})[options.baseCurrency]) > options.amount && options.amount > 0) {
if (options.timeout < new Date().getTime()) {
throw new Meteor.Error('Error.', 'messages.auctions.past')
}
Auctions.insert({
name: name,
description: description,
options: options,
createdBy: Meteor.userId(),
createdAt: new Date().getTime(),
closed:false
createToken(userId) {
if (Meteor.userId() !== userId && !hasPermission(Meteor.userId(), 'user-generate-access-token')) {
throw new Meteor.Error('error-not-authorized', 'Not authorized', { method: 'createToken' });
}
const token = Accounts._generateStampedLoginToken();
Accounts._insertLoginToken(userId, token);
return {
userId,
authToken: token.token,
};
},
});
hashPowerVote: function(hpId, type) {
if (!Meteor.userId()) {
throw new Meteor.Error('Error.', 'messages.login')
}
let mod = UserData.findOne({
_id: this.userId
}, {
fields: {
moderator: true
}
})
if (!mod || !mod.moderator) {
throw new Meteor.Error('Error.', 'mod-only')
}
let hp = HashPower.findOne({
'livechat:saveTrigger'(trigger) {
if (!Meteor.userId() || !hasPermission(Meteor.userId(), 'view-livechat-manager')) {
throw new Meteor.Error('error-not-allowed', 'Not allowed', { method: 'livechat:saveTrigger' });
}
check(trigger, {
_id: Match.Maybe(String),
name: String,
description: String,
enabled: Boolean,
runOnce: Boolean,
conditions: Array,
actions: Array,
});
if (trigger._id) {
return LivechatTrigger.updateById(trigger._id, trigger);
}
export default withTracker(() => {
const subscription = Meteor.subscribe('users.editProfile');
return {
loading: !subscription.ready(),
user: getUserProfile(Meteor.users.findOne({ _id: Meteor.userId() })),
};
})(Profile);
[0]() {
return !Meteor.userId() || !hasPermission(Meteor.userId(), 'edit-other-user-info');
},
});
isProjectOwner(_id) {
return Projects.findOne({ _id }) ? Projects.findOne({ _id }).userId === Meteor.userId() : false
},
colorOpacity(hex, op) {