From 98cb763eeac36b08b3e8b955260815025373cc67 Mon Sep 17 00:00:00 2001 From: Ben Lubar Date: Mon, 25 Jul 2016 09:56:29 -0500 Subject: [PATCH] add "Admin Approval for IPs", which works like Normal for new users and Admin Approval for sockpuppet accounts (#4882) --- src/controllers/authentication.js | 10 ++++++++++ src/controllers/index.js | 2 +- src/middleware/header.js | 2 +- src/views/admin/settings/user.tpl | 2 ++ 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/controllers/authentication.js b/src/controllers/authentication.js index b74233443f58..bc301b187387 100644 --- a/src/controllers/authentication.js +++ b/src/controllers/authentication.js @@ -63,6 +63,16 @@ authenticationController.register = function(req, res, next) { registerAndLoginUser(req, res, userData, next); } else if (registrationType === 'admin-approval') { addToApprovalQueue(req, userData, next); + } else if (registrationType === 'admin-approval-ip') { + db.sortedSetCard('ip:' + req.ip + ':uid', function(err, count) { + if (err) { + next(err); + } else if (count) { + addToApprovalQueue(req, userData, next); + } else { + registerAndLoginUser(req, res, userData, next); + } + }); } } ], function(err, data) { diff --git a/src/controllers/index.js b/src/controllers/index.js index 11215ed22f06..bd6daa6581b5 100644 --- a/src/controllers/index.js +++ b/src/controllers/index.js @@ -115,7 +115,7 @@ Controllers.login = function(req, res, next) { data.alternate_logins = loginStrategies.length > 0; data.authentication = loginStrategies; data.allowLocalLogin = parseInt(meta.config.allowLocalLogin, 10) === 1 || parseInt(req.query.local, 10) === 1; - data.allowRegistration = registrationType === 'normal' || registrationType === 'admin-approval'; + data.allowRegistration = registrationType === 'normal' || registrationType === 'admin-approval' || registrationType === 'admin-approval-ip'; data.allowLoginWith = '[[login:' + allowLoginWith + ']]'; data.breadcrumbs = helpers.buildBreadcrumbs([{text: '[[global:login]]'}]); data.error = req.flash('error')[0] || errorText; diff --git a/src/middleware/header.js b/src/middleware/header.js index dccefcddf7c7..ef73610b92b6 100644 --- a/src/middleware/header.js +++ b/src/middleware/header.js @@ -57,7 +57,7 @@ module.exports = function(app, middleware) { 'brand:logo:url': meta.config['brand:logo:url'] || '', 'brand:logo:alt': meta.config['brand:logo:alt'] || '', 'brand:logo:display': meta.config['brand:logo']?'':'hide', - allowRegistration: registrationType === 'normal' || registrationType === 'admin-approval', + allowRegistration: registrationType === 'normal' || registrationType === 'admin-approval' || registrationType === 'admin-approval-ip', searchEnabled: plugins.hasListeners('filter:search.query'), config: res.locals.config, relative_path: nconf.get('relative_path'), diff --git a/src/views/admin/settings/user.tpl b/src/views/admin/settings/user.tpl index 33972e267c89..575a4a07f961 100644 --- a/src/views/admin/settings/user.tpl +++ b/src/views/admin/settings/user.tpl @@ -124,6 +124,7 @@