/* eslint-disable consistent-return */ import { Meteor } from 'meteor/meteor'; let action; const updateUser = async (userId, { emailAddress, profile }) => { try { await Meteor.users.updateAsync(userId, { $set: { 'emails.0.address': emailAddress, profile, }, }); } catch (exception) { action.reject(`[editProfile.updateUser] ${exception}`); } }; const editProfile = async ({ userId, profile }, promise) => { try { action = promise; await updateUser(userId, profile); action.resolve(); } catch (exception) { action.reject(`[editProfile.handler] ${exception}`); } }; export default options => new Promise((resolve, reject) => editProfile(options, { resolve, reject }));