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'),
|
posts: require('./src/posts.js'),
|
||||||
templates: require('./src/templates.js'),
|
templates: require('./src/templates.js'),
|
||||||
webserver: require('./src/webserver.js'),
|
webserver: require('./src/webserver.js'),
|
||||||
websockets: require('./src/websockets.js')
|
websockets: require('./src/websockets.js'),
|
||||||
|
fs: require('fs')
|
||||||
}
|
}
|
||||||
|
|
||||||
DEVELOPMENT = true;
|
DEVELOPMENT = true;
|
||||||
@@ -13,9 +14,6 @@ var modules = {
|
|||||||
global.configuration = {};
|
global.configuration = {};
|
||||||
global.modules = modules;
|
global.modules = modules;
|
||||||
|
|
||||||
// change this to = null when auth module is complete
|
|
||||||
// global.uid = 1;
|
|
||||||
|
|
||||||
|
|
||||||
process.on('uncaughtException', function(err) {
|
process.on('uncaughtException', function(err) {
|
||||||
// handle the error safely
|
// handle the error safely
|
||||||
@@ -28,7 +26,6 @@ process.on('uncaughtException', function(err) {
|
|||||||
config['ROOT_DIRECTORY'] = __dirname;
|
config['ROOT_DIRECTORY'] = __dirname;
|
||||||
|
|
||||||
modules.templates.init();
|
modules.templates.init();
|
||||||
// modules.webserver.init();
|
|
||||||
modules.websockets.init();
|
modules.websockets.init();
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -169,3 +169,10 @@ footer.footer {
|
|||||||
.pointer;
|
.pointer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.none {
|
||||||
|
display: none !important;
|
||||||
|
}
|
||||||
|
.block {
|
||||||
|
display: block !important;
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
<h1>Login</h1>
|
<h1>Login</h1>
|
||||||
<div class="row-fluid">
|
<div class="row-fluid">
|
||||||
<div class="well span6">
|
<div class="well {login_window:spansize}">
|
||||||
<h4>Login via Username & Password</h4>
|
<h4>Login via Username & Password</h4>
|
||||||
<div class="alert alert-error" id="error" style="display:none">
|
<div class="alert alert-error" id="error" style="display:none">
|
||||||
<button type="button" class="close" data-dismiss="alert">×</button>
|
<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>
|
<button class="btn btn-primary" id="login" type="submit">Login</button> <a href="/reset">Forgot Password?</a>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<div class="well span6">
|
<div class="well span6 {alternate_logins:display}">
|
||||||
<h4>Alternative Logins</h4>
|
<h4>Alternative Logins</h4>
|
||||||
<ul class="alt-logins">
|
<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>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
var fs = require('fs');
|
|
||||||
|
|
||||||
(function(Templates) {
|
(function(Templates) {
|
||||||
|
|
||||||
@@ -7,7 +7,7 @@ var fs = require('fs');
|
|||||||
function loadTemplates(templatesToLoad) {
|
function loadTemplates(templatesToLoad) {
|
||||||
for (var t in templatesToLoad) {
|
for (var t in templatesToLoad) {
|
||||||
(function(file) {
|
(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() {
|
var template = function() {
|
||||||
this.toString = function() {
|
this.toString = function() {
|
||||||
return this.html;
|
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({
|
passport.use(new passportTwitter({
|
||||||
consumerKey: config.twitter.key,
|
consumerKey: config.twitter.key,
|
||||||
consumerSecret: config.twitter.secret,
|
consumerSecret: config.twitter.secret,
|
||||||
@@ -125,6 +125,28 @@ passport.deserializeUser(function(uid, done) {
|
|||||||
res.send(JSON.stringify(data));
|
res.send(JSON.stringify(data));
|
||||||
});
|
});
|
||||||
break;
|
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' :
|
case 'topic' :
|
||||||
global.modules.posts.get(function(data) {
|
global.modules.posts.get(function(data) {
|
||||||
res.send(JSON.stringify(data));
|
res.send(JSON.stringify(data));
|
||||||
|
|||||||
Reference in New Issue
Block a user