mirror of
				https://github.com/NodeBB/NodeBB.git
				synced 2025-11-03 20:45:58 +01:00 
			
		
		
		
	closes #4885
This commit is contained in:
		@@ -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,24 +473,22 @@ app.cacheBuster = null;
 | 
			
		||||
		if (!config.requireEmailConfirmation || !app.user.uid) {
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
		if (!app.user.email) {
 | 
			
		||||
			app.alert({
 | 
			
		||||
		var msg = {
 | 
			
		||||
			alert_id: 'email_confirm',
 | 
			
		||||
				message: '[[error:no-email-to-confirm]]',
 | 
			
		||||
			type: 'warning',
 | 
			
		||||
				timeout: 0,
 | 
			
		||||
				clickfn: function() {
 | 
			
		||||
			timeout: 0
 | 
			
		||||
		};
 | 
			
		||||
 | 
			
		||||
		if (!app.user.email) {
 | 
			
		||||
			msg.message = '[[error:no-email-to-confirm]]';
 | 
			
		||||
			msg.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.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) {
 | 
			
		||||
@@ -498,8 +496,12 @@ app.cacheBuster = null;
 | 
			
		||||
					}
 | 
			
		||||
					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);
 | 
			
		||||
					}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user