mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 11:35:55 +01:00
feat: invites regardless of registration type, invite privilege, groups to join on acceptance (#8786)
* feat: allow invites in normal registration mode + invite privilege * feat: select groups to join from an invite * test: check if groups from invitations have been joined * fix: remove unused variable * feat: write API versions of socket calls * docs: openapi specs for the new routes * test: iron out mongo redis difference * refactor: move inviteGroups endpoint into write API * refactor: use GET /api/v3/users/:uid/invites/groups Instead of GET /api/v3/users/:uid/inviteGroups * fix: no need for /api/v3 prefix when using api module * fix: tests * refactor: change POST /api/v3/users/invite To POST /api/v3/users/:uid/invites * refactor: make helpers.invite awaitable * fix: restrict invite API to self-use only * fix: move invite groups controller to write api, +tests * fix: tests Co-authored-by: Julian Lam <julian@nodebb.org>
This commit is contained in:
@@ -96,7 +96,7 @@ async function renderIfAdminOrGlobalMod(set, req, res) {
|
||||
|
||||
usersController.renderUsersPage = async function (set, req, res) {
|
||||
const userData = await usersController.getUsers(set, req.uid, req.query);
|
||||
render(req, res, userData);
|
||||
await render(req, res, userData);
|
||||
};
|
||||
|
||||
usersController.getUsers = async function (set, uid, query) {
|
||||
@@ -171,10 +171,15 @@ async function render(req, res, data) {
|
||||
data.inviteOnly = registrationType === 'invite-only' || registrationType === 'admin-invite-only';
|
||||
data.adminInviteOnly = registrationType === 'admin-invite-only';
|
||||
data.invites = await user.getInvitesNumber(req.uid);
|
||||
data.showInviteButton = req.loggedIn && (
|
||||
(registrationType === 'invite-only' && (data.isAdmin || !data.maximumInvites || data.invites < data.maximumInvites)) ||
|
||||
(registrationType === 'admin-invite-only' && data.isAdmin)
|
||||
);
|
||||
|
||||
data.showInviteButton = false;
|
||||
if (data.adminInviteOnly) {
|
||||
data.showInviteButton = await privileges.users.isAdministrator(req.uid);
|
||||
} else if (req.loggedIn) {
|
||||
const canInvite = await privileges.users.hasInvitePrivilege(req.uid);
|
||||
data.showInviteButton = canInvite && (!data.maximumInvites || data.invites < data.maximumInvites);
|
||||
}
|
||||
|
||||
data['reputation:disabled'] = meta.config['reputation:disabled'];
|
||||
|
||||
res.append('X-Total-Count', data.userCount);
|
||||
|
||||
Reference in New Issue
Block a user