v1.18.x
barisusakli 9 years ago
parent d9dc65720a
commit 514c12aa68

@ -25,6 +25,7 @@
"email-taken": "Email taken", "email-taken": "Email taken",
"email-not-confirmed": "Your email has not been confirmed yet, please click here to confirm your email.", "email-not-confirmed": "Your email has not been confirmed yet, please click here to confirm your email.",
"email-not-confirmed-chat": "You are unable to chat until your email is confirmed, please click here to confirm your email.", "email-not-confirmed-chat": "You are unable to chat until your email is confirmed, please click here to confirm your email.",
"email-not-confirmed-email-sent": "Your email has not been confirmed yet, please check your inbox for the confirmation email.",
"no-email-to-confirm": "This forum requires email confirmation, please click here to enter an email", "no-email-to-confirm": "This forum requires email confirmation, please click here to enter an email",
"email-confirm-failed": "We could not confirm your email, please try again later.", "email-confirm-failed": "We could not confirm your email, please try again later.",
"confirm-email-already-sent": "Confirmation email already sent, please wait %1 minute(s) to send another one.", "confirm-email-already-sent": "Confirmation email already sent, please wait %1 minute(s) to send another one.",

@ -473,33 +473,35 @@ app.cacheBuster = null;
if (!config.requireEmailConfirmation || !app.user.uid) { if (!config.requireEmailConfirmation || !app.user.uid) {
return; return;
} }
var msg = {
alert_id: 'email_confirm',
type: 'warning',
timeout: 0
};
if (!app.user.email) { if (!app.user.email) {
app.alert({ msg.message = '[[error:no-email-to-confirm]]';
alert_id: 'email_confirm', msg.clickfn = function() {
message: '[[error:no-email-to-confirm]]', app.removeAlert('email_confirm');
type: 'warning', ajaxify.go('user/' + app.user.userslug + '/edit');
timeout: 0, };
clickfn: function() { app.alert(msg);
app.removeAlert('email_confirm'); } else if (!app.user['email:confirmed'] && !app.user.isEmailConfirmSent) {
ajaxify.go('user/' + app.user.userslug + '/edit'); msg.message = err ? err.message : '[[error:email-not-confirmed]]';
} msg.clickfn = function() {
}); app.removeAlert('email_confirm');
} else if (!app.user['email:confirmed']) { socket.emit('user.emailConfirm', {}, function(err) {
app.alert({ if (err) {
alert_id: 'email_confirm', return app.alertError(err.message);
message: err ? err.message : '[[error:email-not-confirmed]]', }
type: 'warning', app.alertSuccess('[[notifications:email-confirm-sent]]');
timeout: 0, });
clickfn: function() { };
app.removeAlert('email_confirm');
socket.emit('user.emailConfirm', {}, function(err) { app.alert(msg);
if (err) { } else if (!app.user['email:confirmed'] && app.user.isEmailConfirmSent) {
return app.alertError(err.message); msg.message = '[[error:email-not-confirmed-email-sent]]';
} app.alert(msg);
app.alertSuccess('[[notifications:email-confirm-sent]]');
});
}
});
} }
}; };

@ -3,6 +3,7 @@
var async = require('async'); var async = require('async');
var nconf = require('nconf'); var nconf = require('nconf');
var db = require('../database');
var user = require('../user'); var user = require('../user');
var meta = require('../meta'); var meta = require('../meta');
var plugins = require('../plugins'); var plugins = require('../plugins');
@ -94,6 +95,12 @@ module.exports = function(app, middleware) {
next(null, userData); next(null, userData);
} }
}, },
isEmailConfirmSent: function(next) {
if (!meta.config.requireEmailConfirmation || !req.uid) {
return next(null, false);
}
db.get('uid:' + req.uid + ':confirm:email:sent', next);
},
navigation: async.apply(navigation.get), navigation: async.apply(navigation.get),
tags: async.apply(meta.tags.parse, res.locals.metaTags, res.locals.linkTags) tags: async.apply(meta.tags.parse, res.locals.metaTags, res.locals.linkTags)
}, function(err, results) { }, function(err, results) {
@ -110,6 +117,7 @@ module.exports = function(app, middleware) {
results.user.isGlobalMod = results.isGlobalMod; results.user.isGlobalMod = results.isGlobalMod;
results.user.uid = parseInt(results.user.uid, 10); results.user.uid = parseInt(results.user.uid, 10);
results.user['email:confirmed'] = parseInt(results.user['email:confirmed'], 10) === 1; results.user['email:confirmed'] = parseInt(results.user['email:confirmed'], 10) === 1;
results.user.isEmailConfirmSent = !!results.isEmailConfirmSent;
if (parseInt(meta.config.disableCustomUserSkins, 10) !== 1 && res.locals.config.bootswatchSkin !== 'default') { if (parseInt(meta.config.disableCustomUserSkins, 10) !== 1 && res.locals.config.bootswatchSkin !== 'default') {
templateValues.bootswatchCSS = '//maxcdn.bootstrapcdn.com/bootswatch/latest/' + res.locals.config.bootswatchSkin + '/bootstrap.min.css'; templateValues.bootswatchCSS = '//maxcdn.bootstrapcdn.com/bootswatch/latest/' + res.locals.config.bootswatchSkin + '/bootstrap.min.css';

@ -28,8 +28,8 @@ var emailer = require('../emailer');
UserEmail.sendValidationEmail = function(uid, email, callback) { UserEmail.sendValidationEmail = function(uid, email, callback) {
callback = callback || function() {}; callback = callback || function() {};
var confirm_code = utils.generateUUID(), var confirm_code = utils.generateUUID();
confirm_link = nconf.get('url') + '/confirm/' + confirm_code; var confirm_link = nconf.get('url') + '/confirm/' + confirm_code;
var emailInterval = meta.config.hasOwnProperty('emailConfirmInterval') ? parseInt(meta.config.emailConfirmInterval, 10) : 10; var emailInterval = meta.config.hasOwnProperty('emailConfirmInterval') ? parseInt(meta.config.emailConfirmInterval, 10) : 10;
@ -97,6 +97,7 @@ var emailer = require('../emailer');
async.series([ async.series([
async.apply(user.setUserField, confirmObj.uid, 'email:confirmed', 1), async.apply(user.setUserField, confirmObj.uid, 'email:confirmed', 1),
async.apply(db.delete, 'confirm:' + code), async.apply(db.delete, 'confirm:' + code),
async.apply(db.delete, 'uid:' + confirmObj.uid + ':confirm:email:sent'),
function(next) { function(next) {
db.sortedSetRemove('users:notvalidated', confirmObj.uid, next); db.sortedSetRemove('users:notvalidated', confirmObj.uid, next);
} }

Loading…
Cancel
Save