diff --git a/imports/api/Users/server/edit-profile.js b/imports/api/Users/server/edit-profile.js index b065fc9..fc4d236 100644 --- a/imports/api/Users/server/edit-profile.js +++ b/imports/api/Users/server/edit-profile.js @@ -1,4 +1,5 @@ /* eslint-disable consistent-return */ + import { Meteor } from 'meteor/meteor'; import { Accounts } from 'meteor/accounts-base'; @@ -6,6 +7,7 @@ let action; const updatePassword = (userId, newPassword) => { try { + throw new Meteor.Error('500', 'Testing failures.'); Accounts.setPassword(userId, newPassword, { logout: false }); } catch (exception) { action.reject(`[editProfile.updatePassword] ${exception}`); @@ -31,13 +33,12 @@ const editProfile = ({ userId, profile }, promise) => { updateUser(userId, profile); if (profile.password) updatePassword(userId, profile.password); - - action.resolve(); } catch (exception) { action.reject(`[editProfile.handler] ${exception}`); } }; + export default options => new Promise((resolve, reject) => editProfile(options, { resolve, reject })); diff --git a/imports/modules/rate-limit.js b/imports/modules/rate-limit.js index 04d4b1c..d98096f 100644 --- a/imports/modules/rate-limit.js +++ b/imports/modules/rate-limit.js @@ -1,18 +1,11 @@ import { Meteor } from 'meteor/meteor'; import { DDPRateLimiter } from 'meteor/ddp-rate-limiter'; -import { _ } from 'meteor/underscore'; - -const fetchMethodNames = methods => _.pluck(methods, 'name'); - -const assignLimits = ({ methods, limit, timeRange }) => { - const methodNames = fetchMethodNames(methods); +export default ({ methods, limit, timeRange }) => { if (Meteor.isServer) { DDPRateLimiter.addRule({ - name(name) { return _.contains(methodNames, name); }, + name(name) { return methods.indexOf(name) > -1; }, connectionId() { return true; }, }, limit, timeRange); } }; - -export default function rateLimit(options) { return assignLimits(options); }