mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-12-22 00:10:25 +01:00
hide alternate login strategies if config is not set
This commit is contained in:
7
app.js
7
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();
|
||||
|
||||
|
||||
|
||||
@@ -169,3 +169,10 @@ footer.footer {
|
||||
.pointer;
|
||||
}
|
||||
}
|
||||
|
||||
.none {
|
||||
display: none !important;
|
||||
}
|
||||
.block {
|
||||
display: block !important;
|
||||
}
|
||||
@@ -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>
|
||||
@@ -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;
|
||||
|
||||
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user