From e55043e5abeab6470ed4a862e14ec8c3829b2c13 Mon Sep 17 00:00:00 2001 From: barisusakli Date: Fri, 12 Aug 2016 01:14:01 +0300 Subject: [PATCH] closes #4867 --- install/web.js | 60 ++++++++++++++++----------------- public/src/installer/install.js | 5 ++- src/views/install/index.tpl | 8 ++--- 3 files changed, 38 insertions(+), 35 deletions(-) diff --git a/install/web.js b/install/web.js index 7d2cfad21a..0f4e645e8a 100644 --- a/install/web.js +++ b/install/web.js @@ -1,16 +1,16 @@ "use strict"; -var winston = require('winston'), - express = require('express'), - bodyParser = require('body-parser'), - fs = require('fs'), - path = require('path'), - less = require('less'), - async = require('async'), - uglify = require('uglify-js'), - nconf = require('nconf'), - app = express(), - server; +var winston = require('winston'); +var express = require('express'); +var bodyParser = require('body-parser'); +var fs = require('fs'); +var path = require('path'); +var less = require('less'); +var async = require('async'); +var uglify = require('uglify-js'); +var nconf = require('nconf'); +var app = express(); +var server; winston.add(winston.transports.File, { filename: 'logs/webinstall.log', @@ -22,13 +22,13 @@ winston.add(winston.transports.File, { level: 'verbose' }); -var web = {}, - scripts = [ - 'public/vendor/xregexp/xregexp.js', - 'public/vendor/xregexp/unicode/unicode-base.js', - 'public/src/utils.js', - 'public/src/installer/install.js' - ]; +var web = {}; +var scripts = [ + 'public/vendor/xregexp/xregexp.js', + 'public/vendor/xregexp/unicode/unicode-base.js', + 'public/src/utils.js', + 'public/src/installer/install.js' +]; web.install = function(port) { port = port || 4567; @@ -62,22 +62,23 @@ function setupRoutes() { } function welcome(req, res) { - var dbs = ['redis', 'mongo'], - databases = []; - - dbs.forEach(function(el) { - databases.push({ + var dbs = ['redis', 'mongo']; + var databases = dbs.map(function(el) { + return { name: el, questions: require('../src/database/' + el).questions - }); + }; }); + var defaults = require('./data/defaults'); + res.render('install/index', { databases: databases, skipDatabaseSetup: !!nconf.get('database'), error: res.locals.error ? true : false, success: res.locals.success ? true : false, - values: req.body + values: req.body, + minimumPasswordLength: defaults.minimumPasswordLength }); } @@ -104,7 +105,6 @@ function install(req, res) { } function launch(req, res) { - var pidFilePath = __dirname + '../pidfile'; res.json({}); server.close(); @@ -146,10 +146,10 @@ function compileJS(callback) { return callback(false); } - var scriptPath = path.join(__dirname, '..'), - result = uglify.minify(scripts.map(function(script) { - return path.join(scriptPath, script); - })); + var scriptPath = path.join(__dirname, '..'); + var result = uglify.minify(scripts.map(function(script) { + return path.join(scriptPath, script); + })); fs.writeFile(path.join(__dirname, '../public/nodebb.min.js'), result.code, callback); diff --git a/public/src/installer/install.js b/public/src/installer/install.js index f7224fb71a..d2e5b64fc8 100644 --- a/public/src/installer/install.js +++ b/public/src/installer/install.js @@ -44,7 +44,7 @@ $('document').ready(function() { if ($('form .admin .error').length) { ev.preventDefault(); $('html, body').animate({'scrollTop': '0px'}, 400); - + return false; } else { $('#submit .fa-spin').removeClass('hide'); @@ -69,6 +69,9 @@ $('document').ready(function() { if (!utils.isPasswordValid(field)) { parent.addClass('error'); help.html('Invalid Password.'); + } else if (field.length < $('[name="admin:password"]').attr('data-minimum-length')) { + parent.addClass('error'); + help.html('Password is too short.'); } else { parent.removeClass('error'); } diff --git a/src/views/install/index.tpl b/src/views/install/index.tpl index 75d6c1e16a..9621632a73 100644 --- a/src/views/install/index.tpl +++ b/src/views/install/index.tpl @@ -72,9 +72,9 @@
- +
-
+
@@ -119,7 +119,7 @@

Congratulations! Your NodeBB has been set-up.

- +

@@ -136,7 +136,7 @@
- +