From a7ed1f97dfed28ad65550c4148994b83d06dc8c6 Mon Sep 17 00:00:00 2001 From: Baris Soner Usakli Date: Tue, 16 Jul 2013 14:44:18 -0400 Subject: [PATCH] delete old email key before setting new one when someone changes their email --- src/user.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/user.js b/src/user.js index 843a099f09..f6d5f0c789 100644 --- a/src/user.js +++ b/src/user.js @@ -230,7 +230,10 @@ var utils = require('./../public/src/utils.js'), if(data[key] !== undefined) { if(key === 'email') { User.setUserField(uid, 'gravatarpicture', User.createGravatarURLFromEmail(data[key])); - RDB.set('email:' + data['email'] +':uid', uid); + user.getUserField(uid, 'email', function(email) { + RDB.del('email:' + email + ':uid'); + RDB.set('email:' + data['email'] + ':uid', uid); + }); } else if(key === 'signature') { data[key] = utils.strip_tags(data[key]); }