Node.js based forum software built for the modern web
hide alternate login strategies if config is not set
psychobunnyc73feeea2a95
diff --git a/app.js b/app.jsindex b9759de5bc..96b367830c 100644--- a/app.js+++ b/app.js@@ -4,7 +4,8 @@ var modules = {posts: require('./src/posts.js'),templates: require('./src/templates.js'),webserver: require('./src/webserver.js'),- websockets: require('./src/websockets.js')+ websockets: require('./src/websockets.js'),+ fs: require('fs')}DEVELOPMENT = true;@@ -13,9 +14,6 @@ var modules = {global.configuration = {};global.modules = modules;-// change this to = null when auth module is complete-// global.uid = 1;-process.on('uncaughtException', function(err) {// handle the error safely@@ -28,7 +26,6 @@ process.on('uncaughtException', function(err) {config['ROOT_DIRECTORY'] = __dirname;modules.templates.init();- // modules.webserver.init();modules.websockets.init();diff --git a/public/css/style.less b/public/css/style.lessindex 06d0cda1e8..19fc47425e 100644--- a/public/css/style.less+++ b/public/css/style.less@@ -168,4 +168,11 @@ footer.footer {.inline-block;.pointer;}+}++.none {+ display: none !important;+}+.block {+ display: block !important;}\ No newline at end of filediff --git a/public/templates/login.tpl b/public/templates/login.tplindex d2f06bef2b..304b8bd180 100644--- a/public/templates/login.tpl+++ b/public/templates/login.tpl@@ -1,6 +1,6 @@<h1>Login</h1><div class="row-fluid">- <div class="well span6">+ <div class="well {login_window:spansize}"><h4>Login via Username & Password</h4><div class="alert alert-error" id="error" style="display:none"><button type="button" class="close" data-dismiss="alert">×</button>@@ -12,10 +12,10 @@<button class="btn btn-primary" id="login" type="submit">Login</button> <a href="/reset">Forgot Password?</a></form></div>- <div class="well span6">+ <div class="well span6 {alternate_logins:display}"><h4>Alternative Logins</h4><ul class="alt-logins">- <li><a href="/auth/twitter"><img src="/images/twitter_login.png" /></a></li>+ <li class="none {twitter:display}"><a href="/auth/twitter"><img src="/images/twitter_login.png" /></a></li></ul></div></div>\ No newline at end of filediff --git a/src/templates.js b/src/templates.jsindex 98e0ed6f99..e56f09f39d 100644--- a/src/templates.js+++ b/src/templates.js@@ -1,4 +1,4 @@-var fs = require('fs');+(function(Templates) {@@ -7,7 +7,7 @@ var fs = require('fs');function loadTemplates(templatesToLoad) {for (var t in templatesToLoad) {(function(file) {- fs.readFile(global.configuration.ROOT_DIRECTORY + '/public/templates/' + file + '.tpl', function(err, html) {+ modules.fs.readFile(global.configuration.ROOT_DIRECTORY + '/public/templates/' + file + '.tpl', function(err, html) {var template = function() {this.toString = function() {return this.html;diff --git a/src/webserver.js b/src/webserver.jsindex 95d55d9d29..789810caf6 100644--- a/src/webserver.js+++ b/src/webserver.js@@ -18,7 +18,7 @@ passport.use(new passportLocal(function(user, password, next) {});}));-if (config.twitter.key.length > 0 && config.twitter.secret.length > 0) {+if (config.twitter && config.twitter.key && config.twitter.key.length > 0 && config.twitter.secret.length > 0) {passport.use(new passportTwitter({consumerKey: config.twitter.key,consumerSecret: config.twitter.secret,@@ -125,6 +125,28 @@ passport.deserializeUser(function(uid, done) {res.send(JSON.stringify(data));});break;+ case 'login' :+ var data = {},+ num_strategies = login_strategies.length;++ if (num_strategies == 0) {+ data = {+ 'login_window:spansize': 'span12',+ 'alternate_logins:display': 'none'+ };+ } else {+ data = {+ 'login_window:spansize': 'span6',+ 'alternate_logins:display': 'block'+ }+ for (var i=0, ii=num_strategies; i<ii; i++) {+ data[login_strategies[i] + ':display'] = 'block';+ }+ }+ console.log(data);+ res.send(JSON.stringify(data));++ break;case 'topic' :global.modules.posts.get(function(data) {res.send(JSON.stringify(data));