Skip to content

Commit

Permalink
refactor: async/await src/user/approval
Browse files Browse the repository at this point in the history
  • Loading branch information
barisusakli committed Oct 15, 2020
1 parent bae0f34 commit 43afe7f
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/user/approval.js
@@ -1,6 +1,5 @@
'use strict';

const async = require('async');
const validator = require('validator');

const db = require('../database');
Expand Down Expand Up @@ -116,14 +115,12 @@ module.exports = function (User) {
delete user.hashedPassword;
return user;
});

users = await async.map(users, async function (user) {
await Promise.all(users.map(async (user) => {
// temporary: see http://www.stopforumspam.com/forum/viewtopic.php?id=6392
// need to keep this for getIPMatchedUsers
user.ip = user.ip.replace('::ffff:', '');
await getIPMatchedUsers(user);
user.customActions = [].concat(user.customActions);
return user;
/*
// then spam prevention plugins, using the "filter:user.getRegistrationQueue" hook can be like:
user.customActions.push({
Expand All @@ -133,7 +130,8 @@ module.exports = function (User) {
icon: 'fa-flag'
});
*/
});
}));

const results = await plugins.fireHook('filter:user.getRegistrationQueue', { users: users });
return results.users;
};
Expand Down

0 comments on commit 43afe7f

Please sign in to comment.