mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-08-30 13:57:59 +02:00
Merge pull request #3908 from pitaj/master
Maximum invites and invites are stored
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
var user = require('../../user'),
|
||||
var async = require('async'),
|
||||
user = require('../../user'),
|
||||
meta = require('../../meta');
|
||||
|
||||
|
||||
@@ -31,12 +32,50 @@ usersController.banned = function(req, res, next) {
|
||||
};
|
||||
|
||||
usersController.registrationQueue = function(req, res, next) {
|
||||
user.getRegistrationQueue(0, -1, function(err, data) {
|
||||
var invitations;
|
||||
async.parallel({
|
||||
users: function(next) {
|
||||
user.getRegistrationQueue(0, -1, next);
|
||||
},
|
||||
invites: function(next) {
|
||||
async.waterfall([
|
||||
function(next) {
|
||||
user.getAllInvites(next);
|
||||
},
|
||||
function(_invitations, next) {
|
||||
invitations = _invitations;
|
||||
async.map(invitations, function(invites, next) {
|
||||
user.getUserField(invites.uid, 'username', next);
|
||||
}, next);
|
||||
},
|
||||
function(usernames, next) {
|
||||
invitations.forEach(function(invites, index) {
|
||||
invites.username = usernames[index];
|
||||
});
|
||||
async.map(invitations, function(invites, next) {
|
||||
async.map(invites.invitations, user.getUsernameByEmail, next);
|
||||
}, next);
|
||||
},
|
||||
function(usernames, next) {
|
||||
invitations.forEach(function(invites, index) {
|
||||
invites.invitations = invites.invitations.map(function(email, i) {
|
||||
return {
|
||||
email: email,
|
||||
username: usernames[index][i] === '[[global:guest]]' ? '' : usernames[index][i]
|
||||
};
|
||||
});
|
||||
});
|
||||
next(null, invitations);
|
||||
}
|
||||
], next);
|
||||
}
|
||||
}, function(err, data) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
res.render('admin/manage/registration', {users: data});
|
||||
})
|
||||
res.render('admin/manage/registration', data);
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
function getUsers(set, req, res, next) {
|
||||
|
||||
@@ -117,7 +117,7 @@ Controllers.register = function(req, res, next) {
|
||||
|
||||
async.waterfall([
|
||||
function(next) {
|
||||
if (registrationType === 'invite-only') {
|
||||
if (registrationType === 'invite-only' || registrationType === 'admin-invite-only') {
|
||||
user.verifyInvitation(req.query, next);
|
||||
} else {
|
||||
next();
|
||||
|
||||
@@ -150,14 +150,27 @@ usersController.getUsersForSearch = function(req, res, next) {
|
||||
};
|
||||
|
||||
function render(req, res, data, next) {
|
||||
plugins.fireHook('filter:users.build', {req: req, res: res, templateData: data}, function(err, data) {
|
||||
plugins.fireHook('filter:users.build', { req: req, res: res, templateData: data }, function(err, data) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
|
||||
data.templateData.inviteOnly = meta.config.registrationType === 'invite-only';
|
||||
var registrationType = meta.config.registrationType;
|
||||
|
||||
data.templateData.maximumInvites = meta.config.maximumInvites;
|
||||
data.templateData.inviteOnly = registrationType === 'invite-only' || registrationType === 'admin-invite-only';
|
||||
data.templateData.adminInviteOnly = registrationType === 'admin-invite-only';
|
||||
data.templateData['reputation:disabled'] = parseInt(meta.config['reputation:disabled'], 10) === 1;
|
||||
res.render('users', data.templateData);
|
||||
|
||||
user.getInvitesNumber(req.uid, function(err, num) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
|
||||
data.templateData.invites = num;
|
||||
res.render('users', data.templateData);
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user