if email isnt confirmed, show a warning in account/edit and let users
resend confirm email
v1.18.x
barisusakli 11 years ago
parent 930f1e4789
commit efe04c12d3

@ -21,6 +21,6 @@
"email-confirmed": "Email Confirmed", "email-confirmed": "Email Confirmed",
"email-confirmed-message": "Thank you for validating your email. Your account is now fully activated.", "email-confirmed-message": "Thank you for validating your email. Your account is now fully activated.",
"email-confirm-error": "An error occurred...", "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(); handleImageChange();
handleImageUpload(); handleImageUpload();
handleEmailConfirm();
handlePasswordChange(); handlePasswordChange();
updateSignature(); updateSignature();
updateImages(); 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() { function handlePasswordChange() {
var currentPassword = $('#inputCurrentPassword'); var currentPassword = $('#inputCurrentPassword');
var password_notify = $('#password-notify'); var password_notify = $('#password-notify');

@ -110,6 +110,8 @@ function getUserDataByUserSlug(userslug, callerUID, callback) {
userData.theirid = userData.uid; userData.theirid = userData.uid;
userData.isSelf = parseInt(callerUID, 10) === parseInt(userData.uid, 10); userData.isSelf = parseInt(callerUID, 10) === parseInt(userData.uid, 10);
userData.disableSignatures = meta.config.disableSignatures !== undefined && parseInt(meta.config.disableSignatures, 10) === 1; 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.followingCount = results.followStats.followingCount;
userData.followerCount = results.followStats.followerCount; userData.followerCount = results.followStats.followerCount;

@ -41,6 +41,7 @@ apiController.getConfig = function(req, res, next) {
config.environment = process.env.NODE_ENV; config.environment = process.env.NODE_ENV;
config.isLoggedIn = !!req.user; config.isLoggedIn = !!req.user;
config['cache-buster'] = meta.config['cache-buster'] || ''; config['cache-buster'] = meta.config['cache-buster'] || '';
config.requireEmailConfirmation = parseInt(meta.config.requireEmailConfirmation, 10) === 1;
config.version = pkg.version; config.version = pkg.version;
if (!req.user) { 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) { SocketUser.increaseViewCount = function(socket, uid, callback) {
if (uid) { if (uid) {
if (socket.uid !== parseInt(uid, 10)) { if (socket.uid !== parseInt(uid, 10)) {

@ -40,7 +40,6 @@ module.exports = function(User) {
} }
next(!available ? new Error('[[error:email-taken]]') : null); next(!available ? new Error('[[error:email-taken]]') : null);
}); });
}); });
} }
@ -102,9 +101,7 @@ module.exports = function(User) {
} }
} }
User.setUserField(uid, field, data[field]); User.setUserField(uid, field, data[field], next);
next();
} }
}; };
@ -136,9 +133,17 @@ module.exports = function(User) {
function(next) { function(next) {
User.setUserField(uid, 'email', newEmail, 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) { function(next) {
if (userData.picture !== userData.uploadedpicture) { if (userData.picture !== userData.uploadedpicture) {
User.setUserField(uid, 'picture', gravatarpicture, next); User.setUserField(uid, 'picture', gravatarpicture, next);
} else {
next();
} }
}, },
], callback); ], callback);

Loading…
Cancel
Save