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

@ -25,6 +25,7 @@
"email-taken": "Email taken",
"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-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",
"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.",

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

@ -3,6 +3,7 @@
var async = require('async');
var nconf = require('nconf');
var db = require('../database');
var user = require('../user');
var meta = require('../meta');
var plugins = require('../plugins');
@ -94,6 +95,12 @@ module.exports = function(app, middleware) {
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),
tags: async.apply(meta.tags.parse, res.locals.metaTags, res.locals.linkTags)
}, function(err, results) {
@ -110,6 +117,7 @@ module.exports = function(app, middleware) {
results.user.isGlobalMod = results.isGlobalMod;
results.user.uid = parseInt(results.user.uid, 10);
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') {
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) {
callback = callback || function() {};
var confirm_code = utils.generateUUID(),
confirm_link = nconf.get('url') + '/confirm/' + confirm_code;
var confirm_code = utils.generateUUID();
var confirm_link = nconf.get('url') + '/confirm/' + confirm_code;
var emailInterval = meta.config.hasOwnProperty('emailConfirmInterval') ? parseInt(meta.config.emailConfirmInterval, 10) : 10;
@ -97,6 +97,7 @@ var emailer = require('../emailer');
async.series([
async.apply(user.setUserField, confirmObj.uid, 'email:confirmed', 1),
async.apply(db.delete, 'confirm:' + code),
async.apply(db.delete, 'uid:' + confirmObj.uid + ':confirm:email:sent'),
function(next) {
db.sortedSetRemove('users:notvalidated', confirmObj.uid, next);
}

Loading…
Cancel
Save