mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 11:35:55 +01:00
closes #1635
if email isnt confirmed, show a warning in account/edit and let users resend confirm email
This commit is contained in:
@@ -21,6 +21,6 @@
|
||||
"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."
|
||||
|
||||
"email-confirm-error-message": "There was a problem validating your email address. Perhaps the code was invalid or has expired.",
|
||||
"email-confirm-sent": "Confirmation email sent."
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ define('forum/account/edit', ['forum/account/header', 'uploader'], function(head
|
||||
|
||||
handleImageChange();
|
||||
handleImageUpload();
|
||||
handleEmailConfirm();
|
||||
handlePasswordChange();
|
||||
updateSignature();
|
||||
updateImages();
|
||||
@@ -138,6 +139,17 @@ define('forum/account/edit', ['forum/account/header', 'uploader'], function(head
|
||||
});
|
||||
}
|
||||
|
||||
function handleEmailConfirm() {
|
||||
$('#confirm-email').on('click', function() {
|
||||
socket.emit('user.emailConfirm', {}, function(err) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
app.alertSuccess('[[notifications:email-confirm-sent]]');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function handlePasswordChange() {
|
||||
var currentPassword = $('#inputCurrentPassword');
|
||||
var password_notify = $('#password-notify');
|
||||
|
||||
@@ -110,6 +110,8 @@ function getUserDataByUserSlug(userslug, callerUID, callback) {
|
||||
userData.theirid = userData.uid;
|
||||
userData.isSelf = parseInt(callerUID, 10) === parseInt(userData.uid, 10);
|
||||
userData.disableSignatures = meta.config.disableSignatures !== undefined && parseInt(meta.config.disableSignatures, 10) === 1;
|
||||
userData['email:confirmed'] = !!parseInt(userData['email:confirmed'], 10);
|
||||
|
||||
|
||||
userData.followingCount = results.followStats.followingCount;
|
||||
userData.followerCount = results.followStats.followerCount;
|
||||
|
||||
@@ -41,6 +41,7 @@ apiController.getConfig = function(req, res, next) {
|
||||
config.environment = process.env.NODE_ENV;
|
||||
config.isLoggedIn = !!req.user;
|
||||
config['cache-buster'] = meta.config['cache-buster'] || '';
|
||||
config.requireEmailConfirmation = parseInt(meta.config.requireEmailConfirmation, 10) === 1;
|
||||
config.version = pkg.version;
|
||||
|
||||
if (!req.user) {
|
||||
|
||||
@@ -24,6 +24,23 @@ SocketUser.emailExists = function(socket, data, callback) {
|
||||
}
|
||||
};
|
||||
|
||||
SocketUser.emailConfirm = function(socket, data, callback) {
|
||||
if (socket.uid && parseInt(meta.config.requireEmailConfirmation, 10) === 1) {
|
||||
user.getUserField(socket.uid, 'email', function(err, email) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
if (!email) {
|
||||
return;
|
||||
}
|
||||
|
||||
user.email.verify(socket.uid, email);
|
||||
callback();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
SocketUser.increaseViewCount = function(socket, uid, callback) {
|
||||
if (uid) {
|
||||
if (socket.uid !== parseInt(uid, 10)) {
|
||||
|
||||
@@ -40,7 +40,6 @@ module.exports = function(User) {
|
||||
}
|
||||
|
||||
next(!available ? new Error('[[error:email-taken]]') : null);
|
||||
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -102,9 +101,7 @@ module.exports = function(User) {
|
||||
}
|
||||
}
|
||||
|
||||
User.setUserField(uid, field, data[field]);
|
||||
|
||||
next();
|
||||
User.setUserField(uid, field, data[field], next);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -136,9 +133,17 @@ module.exports = function(User) {
|
||||
function(next) {
|
||||
User.setUserField(uid, 'email', newEmail, next);
|
||||
},
|
||||
function(next) {
|
||||
if (parseInt(meta.config.requireEmailConfirmation, 10) === 1) {
|
||||
User.email.verify(uid, newEmail);
|
||||
}
|
||||
User.setUserField(uid, 'email:confirmed', 0, next);
|
||||
},
|
||||
function(next) {
|
||||
if (userData.picture !== userData.uploadedpicture) {
|
||||
User.setUserField(uid, 'picture', gravatarpicture, next);
|
||||
} else {
|
||||
next();
|
||||
}
|
||||
},
|
||||
], callback);
|
||||
|
||||
Reference in New Issue
Block a user