mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-05-06 06:27:09 +02:00
Merge branch 'master' of github.com:designcreateplay/NodeBB
This commit is contained in:
@@ -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'));
|
||||
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/twitter/callback', passport.authenticate('twitter', {
|
||||
app.get(strategy.callbackURL, passport.authenticate(strategy.name, {
|
||||
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'
|
||||
}));
|
||||
|
||||
app.get('/auth/google/callback', passport.authenticate('google', {
|
||||
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({
|
||||
|
||||
Reference in New Issue
Block a user