nodebb-plugin-newuser-approval
Advanced tools
Comparing version 0.0.5 to 1.0.0
137
library.js
@@ -1,6 +0,11 @@ | ||
var fs = require('fs'), | ||
groups = module.parent.require('./groups'), | ||
winston = module.parent.require('winston'), | ||
'use strict'; | ||
var winston = module.parent.require('winston'), | ||
Meta = module.parent.require('./meta'), | ||
SocketAdmin = module.parent.require('./socket.io/admin'), | ||
Groups = module.parent.require('./groups'), | ||
User = module.parent.require('./user'), | ||
Posts = module.parent.require('./posts'), | ||
Topics = module.parent.require('./topics'), | ||
Approval = {}, | ||
@@ -11,2 +16,15 @@ nonapprovedUserGroup = null, | ||
Approval.init = function(params, callback) { | ||
SocketAdmin.approval = { | ||
getUnapprovedUsers: function(socket, data, callback) { | ||
Approval.getUnapprovedUsers({userData: true}, callback); | ||
}, | ||
approveUser: function(socket, data, callback) { | ||
Approval.approveUser(data, callback); | ||
}, | ||
deleteUser: function(socket, data, callback) { | ||
Approval.deleteUser(data, callback); | ||
} | ||
}; | ||
function render(req, res, next) { | ||
@@ -33,6 +51,115 @@ res.render('admin/plugins/newuser-approval', {}); | ||
if (nonapprovedUserGroup != null) { | ||
groups.join(nonapprovedUserGroup, userData.uid); | ||
Groups.join(nonapprovedUserGroup, userData.uid); | ||
} | ||
}; | ||
Approval.approveUser = function(userData, callback) { | ||
if (approvedUserGroup != null) { | ||
Groups.leave(nonapprovedUserGroup, userData.uid); | ||
Groups.join(approvedUserGroup, userData.uid, callback); | ||
} | ||
}; | ||
Approval.deleteUser = function(userData, callback) { | ||
User.delete(userData.uid, callback); | ||
}; | ||
Approval.filterTids = function(data, callback) { | ||
Approval.getUnapprovedUsers({userData:false}, function(err, members) { | ||
User.isAdministrator(data.uid, function(err, isAdmin) { | ||
if (!isAdmin) { | ||
Topics.getTopicsFields(data.tids, ['uid'], function(err, fields) { | ||
data.tids = fields.reduce(function(prev, cur, idx) { | ||
if (parseInt(cur.uid, 10) === parseInt(data.uid, 10) || members.indexOf(cur.uid) === -1) { | ||
prev.push(data.tids[idx]); | ||
} | ||
return prev; | ||
}, []); | ||
callback(null, data); | ||
}); | ||
} else { | ||
callback(null, data); | ||
} | ||
}); | ||
}); | ||
}; | ||
Approval.filterCategory = function(data, callback) { | ||
Approval.getUnapprovedUsers({userData:false}, function(err, members) { | ||
User.isAdministrator(data.uid, function(err, isAdmin) { | ||
if (!isAdmin) { | ||
var filtered = []; | ||
if (data.topics && data.topics.length) { | ||
data.topics.forEach( function(topic) { | ||
if (parseInt(topic.uid, 10) === parseInt(data.uid, 10) || members.indexOf(topic.uid) === -1) { | ||
filtered.push(topic); | ||
} | ||
}); | ||
} | ||
callback(null, {topics:filtered,uid:data.uid}); | ||
} else { | ||
callback(null, data); | ||
} | ||
}); | ||
}); | ||
}; | ||
Approval.filterPids = function(data, callback) { | ||
Approval.getUnapprovedUsers({userData:false}, function(err, members) { | ||
User.isAdministrator(data.uid, function(err, isAdmin) { | ||
if (!isAdmin) { | ||
Posts.getPostsFields(data.pids, ['uid'], function(err, fields) { | ||
data.pids = fields.reduce(function(prev, cur, idx) { | ||
if (parseInt(cur.uid, 10) === parseInt(data.uid, 10) || members.indexOf(cur.uid) === -1) { | ||
prev.push(data.pids[idx]); | ||
} | ||
return prev; | ||
}, []); | ||
callback(null, data); | ||
}); | ||
} else { | ||
callback(null, data); | ||
} | ||
}); | ||
}); | ||
}; | ||
Approval.filterPosts = function(data, callback) { | ||
Approval.getUnapprovedUsers({userData:false}, function(err, members) { | ||
User.isAdministrator(data.req.uid, function(err, isAdmin) { | ||
if(!isAdmin) { | ||
data.templateData.posts = data.templateData.posts.reduce(function(prev, cur, idx) { | ||
if (parseInt(cur.uid, 10) === parseInt(data.req.uid, 10) || members.indexOf(cur.uid) === -1) { | ||
prev.push(data.templateData.posts[idx]); | ||
} | ||
return prev; | ||
}, []); | ||
callback(null, data); | ||
} | ||
else { | ||
callback(null, data); | ||
} | ||
}); | ||
}); | ||
}; | ||
Approval.getUnapprovedUsers = function(options, callback) { | ||
Groups.getMembers(nonapprovedUserGroup, 0, -1, function(err, members) { | ||
if (err) { | ||
winston.error(err.message); | ||
} | ||
else { | ||
if(options.userData) { | ||
User.getUsersData(members, callback); | ||
} | ||
else { | ||
callback(null, members); | ||
} | ||
} | ||
}); | ||
}; | ||
Approval.admin = { | ||
@@ -39,0 +166,0 @@ menu: function(custom_header, callback) { |
{ | ||
"name": "nodebb-plugin-newuser-approval", | ||
"version": "0.0.5", | ||
"version": "1.0.0", | ||
"description": "A plugin for NodeBB to allow admins to approve new users.", | ||
@@ -26,4 +26,4 @@ "main": "library.js", | ||
"nbbpm": { | ||
"compatibility": "^0.7.0" | ||
"compatibility": "^0.9.0" | ||
} | ||
} | ||
} |
{ | ||
"id": "nodebb-plugin-newuser-approval" | ||
,"name": "NodeBB New User Approval Plugin" | ||
,"description": "A plugin for NodeBB to allow admins to approve new users." | ||
,"url": "https://github.com/pichalite/nodebb-plugin-newuser-approval" | ||
,"library": "./library.js" | ||
,"staticDirs": { | ||
"public": "public" | ||
} | ||
,"templates": "public/templates" | ||
,"hooks": [ | ||
"id": "nodebb-plugin-newuser-approval", | ||
"name": "NodeBB New User Approval Plugin", | ||
"description": "A plugin for NodeBB to allow admins to approve new users.", | ||
"url": "https://github.com/pichalite/nodebb-plugin-newuser-approval", | ||
"library": "./library.js", | ||
"templates": "templates", | ||
"hooks": [ | ||
{ "hook": "static:app.load", "method": "init" }, | ||
{ "hook": "filter:admin.header.build", "method": "admin.menu" }, | ||
{ "hook": "action:user.create", "method": "moveUserToGroup" } | ||
] | ||
{ "hook": "action:user.create", "method": "moveUserToGroup" }, | ||
{ "hook": "filter:privileges.topics.filter", "method": "filterTids" }, | ||
{ "hook": "filter:category.topics.get", "method": "filterCategory" }, | ||
{ "hook": "filter:privileges.posts.filter", "method": "filterPids" }, | ||
{ "hook": "filter:categories.recent", "method": "filterPids" }, | ||
{ "hook": "filter:topic.build", "method": "filterPosts"} | ||
], | ||
"scripts": [ | ||
"public/js/acp.js" | ||
] | ||
} |
# NodeBB New User Approval | ||
This NodeBB plugin adds new users to a group set under plugin settings. Admins later can approve the users. When the admins approves, the user is them moved to a group also set under plugin settings. | ||
This NodeBB plugin adds new users to a group set under plugin settings. Admins can see a list of new users and decide to either approve or delete the users. When the admin approves, the user is then moved to a group also set under plugin settings. | ||
To customise options for this plugin, please consult the "New User Approval" page in the administration panel, under the "Plugins" heading. | ||
Until the user is approved, all their topics and posts will be hidden from other users. Admins and users themselves can see them. | ||
To customise options for this plugin, please consult the "New User Approval" page in the administration panel, under the "Plugins" menu option. | ||
##Installation | ||
npm install nodebb-plugin-newuser-approval | ||
npm install nodebb-plugin-newuser-approval | ||
### Credits | ||
nodebb-plugin-support-forum by [Julian](https://github.com/julianlam) |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
52805
16
233
0
16
0
1