Merge branch 'master' of github.com:designcreateplay/NodeBB

v1.18.x
Julian Lam 11 years ago
commit 670986f7ef

@ -1,24 +1,7 @@
define(function() {
var Login = {};
Login.init = function() {
// Alternate Logins
var altLoginEl = document.querySelector('.alt-logins');
altLoginEl.addEventListener('click', function(e) {
var target;
switch (e.target.nodeName) {
case 'LI':
target = e.target;
break;
case 'I':
target = e.target.parentNode;
break;
}
if (target) {
document.location.href = target.getAttribute('data-url');
}
});
Login.init = function() {
$('#login').on('click', function() {
var loginData = {
'username': $('#username').val(),

@ -134,11 +134,6 @@ define(function() {
}
});
// Alternate Logins
$('.alt-logins li').on('click', function(e) {
document.location.href = $(this).attr('data-url');
});
function validateForm() {
validationError = false;

@ -49,14 +49,16 @@
</div>
</div>
<div class="col-md-6 {alternate_logins:display}">
<!-- IF alternate_logins -->
<div class="col-md-6">
<div class="well well-lg">
<h4>[[login:alternative_logins]]</h4>
<ul class="alt-logins">
<li data-url="/auth/twitter" class="twitter {twitter:display}"><i class="fa fa-twitter-square fa-3x"></i></li>
<li data-url="/auth/google" class="google {google:display}"><i class="fa fa-google-plus-square fa-3x"></i></li>
<li data-url="/auth/facebook" class="facebook {facebook:display}"><i class="fa fa-facebook-square fa-3x"></i></li>
<!-- BEGIN authentication -->
<li class="{authentication.name}"><a rel="nofollow" href="{authentication.url}"><i class="fa fa-{authentication.icon}-square fa-3x"></i></a></li>
<!-- END authentication -->
</ul>
</div>
</div>
<!-- ENDIF alternate_logins -->
</div>

@ -69,14 +69,17 @@
</form>
</div>
</div>
<div class="col-md-6 {alternate_logins:display}">
<!-- IF alternate_logins -->
<div class="col-md-6">
<div class="well well-lg">
<h4>[[register:alternative_registration]]</h4>
<ul class="alt-logins">
<li data-url="/auth/twitter" class="twitter {twitter:display}"><i class="fa fa-twitter-square fa-3x"></i></li>
<li data-url="/auth/google" class="google {google:display}"><i class="fa fa-google-plus-square fa-3x"></i></li>
<li data-url="/auth/facebook" class="facebook {facebook:display}"><i class="fa fa-facebook-square fa-3x"></i></li>
<!-- BEGIN authentication -->
<li class="{authentication.name}"><a rel="nofollow" href="{authentication.url}"><i class="fa fa-{authentication.icon}-square fa-3x"></i></a></li>
<!-- END authentication -->
</ul>
</div>
</div>
<!-- ENDIF alternate_logins -->
</div>

@ -72,18 +72,17 @@ var user = require('../user'),
if (num_strategies == 0) {
data = {
'login_window:spansize': 'col-md-12',
'alternate_logins:display': 'none'
'alternate_logins': false
};
} else {
data = {
'login_window:spansize': 'col-md-6',
'alternate_logins:display': 'block'
}
for (var i = 0, ii = num_strategies; i < ii; i++) {
data[login_strategies[i] + ':display'] = 'active';
'alternate_logins': true
}
}
data.authentication = login_strategies;
data.token = res.locals.csrf_token;
res.json(data);
@ -97,18 +96,17 @@ var user = require('../user'),
if (num_strategies == 0) {
data = {
'register_window:spansize': 'col-md-12',
'alternate_logins:display': 'none'
'alternate_logins': false
};
} else {
data = {
'register_window:spansize': 'col-md-6',
'alternate_logins:display': 'block'
}
for (var i = 0, ii = num_strategies; i < ii; i++) {
data[login_strategies[i] + ':display'] = 'active';
'alternate_logins': true
}
}
data.authentication = login_strategies;
data.token = res.locals.csrf_token;
data.minimumUsernameLength = meta.config['minimumUsernameLength'];
data.maximumUsernameLength = meta.config['maximumUsernameLength'];

@ -32,7 +32,13 @@
});
}));
login_strategies.push('twitter');
login_strategies.push({
name: 'twitter',
url: '/auth/twitter',
callbackURL: '/auth/twitter/callback',
icon: 'twitter',
scope: ''
});
}
if (meta.config['social:google:id'] && meta.config['social:google:secret']) {
@ -49,7 +55,13 @@
});
}));
login_strategies.push('google');
login_strategies.push({
name: 'google',
url: '/auth/google',
callbackURL: '/auth/google/callback',
icon: 'google-plus',
scope: 'https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email'
});
}
if (meta.config['social:facebook:app_id'] && meta.config['social:facebook:secret']) {
@ -66,7 +78,13 @@
});
}));
login_strategies.push('facebook');
login_strategies.push({
name: 'facebook',
url: '/auth/facebook',
callbackURL: '/auth/facebook/callback',
icon: 'facebook',
scope: 'email'
});
}
passport.serializeUser(function(user, done) {
@ -103,38 +121,18 @@
res.send(200)
});
if (login_strategies.indexOf('twitter') !== -1) {
app.get('/auth/twitter', passport.authenticate('twitter'));
app.get('/auth/twitter/callback', passport.authenticate('twitter', {
successRedirect: '/',
failureRedirect: '/login'
}));
}
if (login_strategies.indexOf('google') !== -1) {
app.get('/auth/google', passport.authenticate('google', {
scope: 'https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email'
for (var i in login_strategies) {
var strategy = login_strategies[i];
app.get(strategy.url, passport.authenticate(strategy.name, {
scope: strategy.scope
}));
app.get('/auth/google/callback', passport.authenticate('google', {
app.get(strategy.callbackURL, passport.authenticate(strategy.name, {
successRedirect: '/',
failureRedirect: '/login'
}));
}
if (login_strategies.indexOf('facebook') !== -1) {
app.get('/auth/facebook', passport.authenticate('facebook', {
scope: 'email'
}));
app.get('/auth/facebook/callback', passport.authenticate('facebook', {
successRedirect: '/',
failureRedirect: '/login'
}));
}
app.get('/reset/:code', function(req, res) {
app.build_header({

Loading…
Cancel
Save