From 5792946a161c151c5406a97d884ae63fb635a2e5 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Tue, 23 Apr 2013 22:35:03 -0400 Subject: [PATCH] added DEL support to redis wrapper lib --- public/templates/reset_code.tpl | 16 +++++++++++++--- src/redis.js | 4 ++++ src/user.js | 7 ++++++- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/public/templates/reset_code.tpl b/public/templates/reset_code.tpl index 8e480b5ea3..8d98b8e0a6 100644 --- a/public/templates/reset_code.tpl +++ b/public/templates/reset_code.tpl @@ -5,8 +5,12 @@ Password Changed

+
@@ -20,10 +24,16 @@ (function() { var resetEl = document.getElementById('reset'), password = document.getElementById('password'), - repeat = document.getElementById('repeat'); + repeat = document.getElementById('repeat'), + noticeEl = document.getElementById('notice'); resetEl.addEventListener('click', function() { - if (password.value === repeat.value) { + if (password.value.length < 6) { + $('#error').hide(); + noticeEl.querySelector('strong').value = 'Invalid Password'; + noticeEl.querySelector('p').value = 'The password entered it too short, please pick a different password!'; + noticeEl.style.display = 'auto'; + } else if (password.value === repeat.value) { alert("match"); } }, false); diff --git a/src/redis.js b/src/redis.js index 100e6a70c6..65827da2e2 100644 --- a/src/redis.js +++ b/src/redis.js @@ -32,6 +32,10 @@ }); }; + RedisDB.del = function(key, callback) { + db.del(key); + } + // Atomic Operations RedisDB.incr = function(key, callback, error_handler) { db.incr(key, function(error, data) { diff --git a/src/user.js b/src/user.js index 54544e54ea..3e07fe92ed 100644 --- a/src/user.js +++ b/src/user.js @@ -115,7 +115,12 @@ var config = require('../config.js'), if (uid !== null) { RDB.get('reset:' + code + ':expiry', function(expiry) { if (expiry >= +new Date()/1000|0) global.socket.emit('user:reset.valid', { valid: true }); - else global.socket.emit('user:reset.valid', { valid: false }); + else { + // Expired, delete from db + RDB.del('reset:' + code + ':uid'); + RDB.del('reset:' + code + ':expiry'); + global.socket.emit('user:reset.valid', { valid: false }); + } }); } else global.socket.emit('user:reset.valid', { valid: false }); });