mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 11:35:55 +01:00
@@ -66,5 +66,9 @@
|
|||||||
{
|
{
|
||||||
"field": "chatMessagesToDisplay",
|
"field": "chatMessagesToDisplay",
|
||||||
"value": 50
|
"value": 50
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"field": "requireEmailConfirmation",
|
||||||
|
"value": 1
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
"username-taken": "Username taken",
|
"username-taken": "Username taken",
|
||||||
"email-taken": "Email taken",
|
"email-taken": "Email taken",
|
||||||
|
"email-not-confirmed": "Your email is not confirmed",
|
||||||
|
|
||||||
"username-too-short": "User name too short",
|
"username-too-short": "User name too short",
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,11 @@
|
|||||||
"upvoted_your_post": "<strong>%1</strong> has upvoted your post.",
|
"upvoted_your_post": "<strong>%1</strong> has upvoted your post.",
|
||||||
"favourited_your_post": "<strong>%1</strong> has favourited your post.",
|
"favourited_your_post": "<strong>%1</strong> has favourited your post.",
|
||||||
"user_flagged_post": "<strong>%1</strong> flagged a post.",
|
"user_flagged_post": "<strong>%1</strong> flagged a post.",
|
||||||
"user_posted_to" : "<strong>%1</strong> has posted a reply to: <strong>%2</strong>"
|
"user_posted_to" : "<strong>%1</strong> has posted a reply to: <strong>%2</strong>",
|
||||||
|
|
||||||
|
"email-confirmed": "Email Confirmed",
|
||||||
|
"email-confirmed-message": "Thank you for validating your email. Your account is now fully activated.",
|
||||||
|
"email-confirm-error": "An error occurred...",
|
||||||
|
"email-confirm-error-message": "There was a problem validating your email address. Perhaps the code was invalid or has expired."
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -210,20 +210,7 @@ Controllers.register = function(req, res, next) {
|
|||||||
|
|
||||||
Controllers.confirmEmail = function(req, res, next) {
|
Controllers.confirmEmail = function(req, res, next) {
|
||||||
user.email.confirm(req.params.code, function (data) {
|
user.email.confirm(req.params.code, function (data) {
|
||||||
if (data.status === 'ok') {
|
data.status = data.status === 'ok';
|
||||||
data = {
|
|
||||||
'alert-class': 'alert-success',
|
|
||||||
title: 'Email Confirmed',
|
|
||||||
text: 'Thank you for vaidating your email. Your account is now fully activated.'
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
data = {
|
|
||||||
'alert-class': 'alert-danger',
|
|
||||||
title: 'An error occurred...',
|
|
||||||
text: 'There was a problem validating your email address. Perhaps the code was invalid or has expired.'
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
res.render('confirm', data);
|
res.render('confirm', data);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -25,12 +25,12 @@ var groups = require('../groups'),
|
|||||||
settings: {}
|
settings: {}
|
||||||
};
|
};
|
||||||
|
|
||||||
SocketAdmin.before = function(socket, next) {
|
SocketAdmin.before = function(socket, method, next) {
|
||||||
user.isAdministrator(socket.uid, function(err, isAdmin) {
|
user.isAdministrator(socket.uid, function(err, isAdmin) {
|
||||||
if (!err && isAdmin) {
|
if (!err && isAdmin) {
|
||||||
next();
|
next();
|
||||||
} else {
|
} else {
|
||||||
winston.warn('[socket.io] Call to admin method blocked (accessed by uid ' + socket.uid + ')');
|
winston.warn('[socket.io] Call to admin method ( ' + method + ' ) blocked (accessed by uid ' + socket.uid + ')');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -165,7 +165,7 @@ Sockets.init = function(server) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (Namespaces[namespace].before) {
|
if (Namespaces[namespace].before) {
|
||||||
Namespaces[namespace].before(socket, function() {
|
Namespaces[namespace].before(socket, payload.name, function() {
|
||||||
callMethod(methodToCall);
|
callMethod(methodToCall);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
17
src/user.js
17
src/user.js
@@ -155,21 +155,20 @@ var bcrypt = require('bcryptjs'),
|
|||||||
|
|
||||||
User.isReadyToPost = function(uid, callback) {
|
User.isReadyToPost = function(uid, callback) {
|
||||||
async.parallel({
|
async.parallel({
|
||||||
banned: function(next) {
|
userData: function(next) {
|
||||||
User.getUserField(uid, 'banned', next);
|
User.getUserFields(uid, ['banned', 'lastposttime', 'email', 'email:confirmed'], next);
|
||||||
},
|
},
|
||||||
exists: function(next) {
|
exists: function(next) {
|
||||||
db.exists('user:' + uid, next);
|
db.exists('user:' + uid, next);
|
||||||
},
|
|
||||||
lastposttime: function(next) {
|
|
||||||
User.getUserField(uid, 'lastposttime', next);
|
|
||||||
}
|
}
|
||||||
}, function(err, results) {
|
}, function(err, results) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return callback(err);
|
return callback(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parseInt(results.banned, 10) === 1) {
|
var userData = results.userData;
|
||||||
|
|
||||||
|
if (parseInt(userData.banned, 10) === 1) {
|
||||||
return callback(new Error('[[error:user-banned]]'));
|
return callback(new Error('[[error:user-banned]]'));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -177,7 +176,11 @@ var bcrypt = require('bcryptjs'),
|
|||||||
return callback(new Error('[[error:no-user]]'));
|
return callback(new Error('[[error:no-user]]'));
|
||||||
}
|
}
|
||||||
|
|
||||||
var lastposttime = results.lastposttime;
|
if (userData.email && (parseInt(meta.config.requireEmailConfirmation, 10) === 1 || meta.config.requireEmailConfirmation === undefined) && parseInt(userData['email:confirmed'], 10) !== 1) {
|
||||||
|
return callback(new Error('[[error:email-not-confirmed]]'));
|
||||||
|
}
|
||||||
|
|
||||||
|
var lastposttime = userData.lastposttime;
|
||||||
if (!lastposttime) {
|
if (!lastposttime) {
|
||||||
lastposttime = 0;
|
lastposttime = 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -137,7 +137,7 @@ module.exports = function(User) {
|
|||||||
|
|
||||||
if (userData.email !== undefined) {
|
if (userData.email !== undefined) {
|
||||||
db.setObjectField('email:uid', userData.email, uid);
|
db.setObjectField('email:uid', userData.email, uid);
|
||||||
if (parseInt(uid, 10) !== 1) {
|
if (parseInt(uid, 10) !== 1 && (parseInt(meta.config.requireEmailConfirmation, 10) === 1 || meta.config.requireEmailConfirmation === undefined)) {
|
||||||
User.email.verify(uid, userData.email);
|
User.email.verify(uid, userData.email);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,7 +45,6 @@ var async = require('async'),
|
|||||||
db.expireAt('confirm:' + confirm_code, Math.floor(Date.now() / 1000 + 60 * 60 * 2), next);
|
db.expireAt('confirm:' + confirm_code, Math.floor(Date.now() / 1000 + 60 * 60 * 2), next);
|
||||||
}
|
}
|
||||||
], function(err) {
|
], function(err) {
|
||||||
// Send intro email w/ confirm code
|
|
||||||
user.getUserField(uid, 'username', function(err, username) {
|
user.getUserField(uid, 'username', function(err, username) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return winston.error(err.message);
|
return winston.error(err.message);
|
||||||
@@ -73,7 +72,7 @@ var async = require('async'),
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (confirmObj && confirmObj.uid && confirmObj.email) {
|
if (confirmObj && confirmObj.uid && confirmObj.email) {
|
||||||
db.setObjectField('email:confirmed', confirmObj.email, '1', function() {
|
user.setUserField(confirmObj.uid, 'email:confirmed', 1, function() {
|
||||||
callback({
|
callback({
|
||||||
status: 'ok'
|
status: 'ok'
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user