Skip to content

Node.js based forum software built for the modern web

closes #1263

barisusakli2195b2038529
diff --git a/app.js b/app.js
index 497f6514c2..0fe5ba1d8a 100644
--- a/app.js
+++ b/app.js
@@ -77,24 +77,7 @@ if (!nconf.get('help') && !nconf.get('setup') && !nconf.get('install') && !nconf
} else if (nconf.get('upgrade')) {
upgrade();
} else if (nconf.get('reset')) {
- if (nconf.get('themes')) {
- resetThemes();
- } else if (nconf.get('plugins')) {
- resetPlugins();
- } else if (nconf.get('widgets')) {
- resetWidgets();
- } else if (nconf.get('all')) {
- require('async').series([resetWidgets, resetThemes, resetPlugins], function(err) {
- if (!err) {
- winston.info('[reset] Reset complete.');
- } else {
- winston.error('[reset] Errors were encountered while resetting your forum settings: ' + err.message);
- }
- process.exit();
- });
- } else {
- console.log('no match');
- }
+ reset();
} else {
displayHelp();
}
@@ -215,6 +198,51 @@ function upgrade() {
});
}
+function reset() {
+ if (nconf.get('themes')) {
+ resetThemes();
+ } else if (nconf.get('plugins')) {
+ resetPlugins();
+ } else if (nconf.get('widgets')) {
+ resetWidgets();
+ } else if (nconf.get('settings')) {
+ resetSettings();
+ } else if (nconf.get('all')) {
+ require('async').series([resetWidgets, resetThemes, resetPlugins, resetSettings], function(err) {
+ if (!err) {
+ winston.info('[reset] Reset complete.');
+ } else {
+ winston.error('[reset] Errors were encountered while resetting your forum settings: ' + err.message);
+ }
+ process.exit();
+ });
+ } else {
+ console.log('no match');
+ }
+}
+
+function resetSettings(callback) {
+ loadConfig();
+
+ require('./src/database').init(function(err) {
+ if (err) {
+ if (typeof callback === 'function') {
+ return callback(err);
+ }
+ process.exit();
+ return;
+ }
+ var meta = require('./src/meta');
+ meta.configs.set('allowLocalLogin', 1, function(err) {
+ if (typeof callback === 'function') {
+ callback(err);
+ } else {
+ process.exit();
+ }
+ });
+ });
+}
+
function resetThemes(callback) {
loadConfig();
diff --git a/src/controllers/index.js b/src/controllers/index.js
index 2e206d3217..ca48aaf051 100644
--- a/src/controllers/index.js
+++ b/src/controllers/index.js
@@ -186,6 +186,7 @@ Controllers.login = function(req, res, next) {
data.authentication = login_strategies;
data.token = res.locals.csrf_token;
data.showResetLink = emailersPresent;
+ data.allowLocalLogin = meta.config.allowLocalLogin === undefined || parseInt(meta.config.allowLocalLogin, 10) === 1;
res.render('login', data);
};
diff --git a/src/install.js b/src/install.js
index cde9fd1090..e530aa274f 100644
--- a/src/install.js
+++ b/src/install.js
@@ -225,6 +225,9 @@ var async = require('async'),
}, {
field: 'allowRegistration',
value: 1
+ }, {
+ field: 'allowLocalLogin',
+ value: 1
}, {
field: 'allowFileUploads',
value: 0
diff --git a/src/routes/authentication.js b/src/routes/authentication.js
index 1098a1e489..a2d9f66e44 100644
--- a/src/routes/authentication.js
+++ b/src/routes/authentication.js
@@ -29,6 +29,10 @@
}
function login(req, res, next) {
+ if(meta.config.allowLocalLogin !== undefined && parseInt(meta.config.allowLocalLogin, 10) === 0) {
+ return res.send(403);
+ }
+
passport.authenticate('local', function(err, userData, info) {
if (err) {
return next(err);