mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-07-12 11:01:27 +02:00
Merge branch 'master' of github.com:designcreateplay/NodeBB
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"login": "Login",
|
||||
"username": "Username",
|
||||
"username": "Username / Email",
|
||||
"password": "Password",
|
||||
"remember_me": "Remember Me?",
|
||||
"forgot_password": "Forgot Password?",
|
||||
|
||||
@@ -191,6 +191,7 @@ var ajaxify = {};
|
||||
}
|
||||
}
|
||||
|
||||
$('#content [widget-area] img').addClass('img-responsive')
|
||||
checkCallback();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -178,7 +178,12 @@ define(['composer', 'forum/pagination'], function(composer, pagination) {
|
||||
numTopics = topics.length;
|
||||
|
||||
$('#topics-container, .category-sidebar').removeClass('hidden');
|
||||
$('#category-no-topics').remove();
|
||||
|
||||
var noTopicsWarning = $('#category-no-topics');
|
||||
if (noTopicsWarning.length) {
|
||||
noTopicsWarning.remove();
|
||||
ajaxify.renderWidgets('category', window.location.pathname.slice(1));
|
||||
}
|
||||
|
||||
if (numTopics > 0) {
|
||||
for (var x = 0; x < numTopics; x++) {
|
||||
@@ -204,10 +209,7 @@ define(['composer', 'forum/pagination'], function(composer, pagination) {
|
||||
topic.find('span.timeago').timeago();
|
||||
app.createUserTooltips();
|
||||
|
||||
|
||||
ajaxify.renderWidgets('category', window.location.pathname.slice(1), function() {
|
||||
$(window).trigger('action:categories.new_topic.loaded');
|
||||
});
|
||||
$(window).trigger('action:categories.new_topic.loaded');
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
@@ -59,14 +59,29 @@
|
||||
});
|
||||
})(req, res, next);
|
||||
}
|
||||
|
||||
|
||||
function register(req, res) {
|
||||
if(meta.config.allowRegistration !== undefined && parseInt(meta.config.allowRegistration, 10) === 0) {
|
||||
return res.send(403);
|
||||
}
|
||||
|
||||
user.create({username: req.body.username, password: req.body.password, email: req.body.email, ip: req.ip}, function(err, uid) {
|
||||
if (err === null && uid) {
|
||||
var userData = {
|
||||
username: req.body.username,
|
||||
password: req.body.password,
|
||||
email: req.body.email,
|
||||
ip: req.ip
|
||||
};
|
||||
|
||||
plugins.fireHook('filter:register.check', userData, function(err, userData) {
|
||||
if (err) {
|
||||
return res.redirect(nconf.get('relative_path') + '/register');
|
||||
}
|
||||
|
||||
user.create(userData, function(err, uid) {
|
||||
if (err || !uid) {
|
||||
return res.redirect(nconf.get('relative_path') + '/register');
|
||||
}
|
||||
|
||||
req.login({
|
||||
uid: uid
|
||||
}, function() {
|
||||
@@ -79,9 +94,7 @@
|
||||
res.redirect(nconf.get('relative_path') + '/');
|
||||
}
|
||||
});
|
||||
} else {
|
||||
res.redirect(nconf.get('relative_path') + '/register');
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -121,8 +134,20 @@
|
||||
}
|
||||
|
||||
app.post('/logout', logout);
|
||||
app.post('/login', login);
|
||||
app.post('/register', register);
|
||||
app.post('/login', function(req, res, next) {
|
||||
if (req.body.username && utils.isEmailValid(req.body.username)) {
|
||||
user.getUsernameByEmail(req.body.username, function(err, username) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
req.body.username = username ? username : req.body.username;
|
||||
login(req, res, next);
|
||||
});
|
||||
} else {
|
||||
login(req, res, next);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
@@ -412,6 +412,15 @@ var bcrypt = require('bcryptjs'),
|
||||
db.getObjectField('email:uid', email, callback);
|
||||
};
|
||||
|
||||
User.getUsernameByEmail = function(email, callback) {
|
||||
db.getObjectField('email:uid', email, function(err, uid) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
User.getUserField(uid, 'username', callback);
|
||||
});
|
||||
};
|
||||
|
||||
User.isModerator = function(uid, cid, callback) {
|
||||
groups.isMemberByGroupName(uid, 'cid:' + cid + ':privileges:mods', callback);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user