Skip to content

Node.js based forum software built for the modern web

added DEL support to redis wrapper lib

Julian Lam5792946a161c
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 @@
<strong>Password Changed</strong>
<p></p>
</div>
+ <div class="alert" id="notice" style="display:none">
+ <strong></strong>
+ <p></p>
+ </div>
<div class="alert alert-error" id="error" style="display:none">
- <strong>Incrrect Reset Code</strong>
+ <strong>Incorrect Reset Code</strong>
<p>The reset code received was incorrect. Please try again, or <a href="/reset">request a new reset code</a></p>
</div>
<div id="reset-form">
@@ -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 });
});