diff --git a/.gitignore b/.gitignore
index 81ff636051..81dff4b4a9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,4 +5,4 @@
npm-debug.log
node_modules/
sftp-config.json
-public/config.json
+public/config.json
\ No newline at end of file
diff --git a/public/src/templates.js b/public/src/templates.js
index a62094fc8f..5e1c11f0a6 100644
--- a/public/src/templates.js
+++ b/public/src/templates.js
@@ -13,7 +13,7 @@ function loadTemplates(templatesToLoad) {
}
function templates_init() {
- loadTemplates(['register', 'home', 'login']);
+ loadTemplates(['register', 'home', 'login', 'reset']);
}
templates_init();
\ No newline at end of file
diff --git a/public/templates/login.tpl b/public/templates/login.tpl
index 28b4f86eec..85e3ddf419 100644
--- a/public/templates/login.tpl
+++ b/public/templates/login.tpl
@@ -6,7 +6,8 @@
-
+
+ Forgot Password?
\ No newline at end of file
diff --git a/src/templates.js b/src/templates.js
index 13dcd694cb..39576a5bef 100644
--- a/src/templates.js
+++ b/src/templates.js
@@ -15,7 +15,7 @@ var fs = require('fs');
}
Templates.init = function() {
- loadTemplates(['header', 'footer', 'register', 'home', 'login']);
+ loadTemplates(['header', 'footer', 'register', 'home', 'login', 'reset']);
}
}(exports));
\ No newline at end of file
diff --git a/src/user.js b/src/user.js
index d19c4321d8..bb399ddff2 100644
--- a/src/user.js
+++ b/src/user.js
@@ -35,7 +35,7 @@ var RDB = require('./redis.js');
};
- User.create = function(username, password) {
+ User.create = function(username, password, email) {
if (current_uid) {
return; global.socket.emit('user.create', {'status': 0, 'message': 'Only anonymous users can register a new account.'});
}
@@ -54,6 +54,8 @@ var RDB = require('./redis.js');
RDB.set('username:' + username + ':uid', uid);
RDB.set('uid:' + uid + ':username', username);
RDB.set('uid:' + uid + ':password', password);
+ RDB.set('uid:' + uid + ':email', email);
+ RDB.set('email:' + email, uid);
RDB.incr('user:count', function(count) {
io.sockets.emit('user.count', {count: count});
@@ -93,5 +95,13 @@ var RDB = require('./redis.js');
RDB.get('username:' + username + ':uid', callback);
};
-
+ User.email = {
+ exists: function(email) {
+ RDB.get('email:' + email, function(exists) {
+ console.log('email:' + email, exists);
+ exists = !!exists;
+ global.socket.emit('user.email.exists', { exists: exists });
+ });
+ }
+ }
}(exports));
\ No newline at end of file
diff --git a/src/webserver.js b/src/webserver.js
index dbbb65ff4f..b131c19330 100644
--- a/src/webserver.js
+++ b/src/webserver.js
@@ -7,22 +7,17 @@ var express = require('express'),
(function(app) {
var templates = global.templates;
- app.get('/test', function(req, res) {
- var body = 'testing';
- res.send(body);
- });
app.get('/', function(req, res) {
- console.log(templates['header']);
res.send(templates['header'] + templates['home'] + templates['footer']);
});
app.get('/login', function(req, res) {
- var body = templates['header'] + templates['login'] + templates['footer'];
- res.setHeader('Content-Type', 'text/html');
- res.setHeader('Content-Length', body.length);
- res.end(body);
+ res.send(templates['header'] + templates['login'] + templates['footer']);
});
+ app.get('/reset', function(req, res) {
+ res.send(templates['header'] + templates['reset'] + templates['footer']);
+ });
app.get('/register', function(req, res) {
res.send(templates['header'] + templates['register'] + templates['footer']);
diff --git a/src/websockets.js b/src/websockets.js
index 521f76702c..ea3486d18a 100644
--- a/src/websockets.js
+++ b/src/websockets.js
@@ -23,7 +23,7 @@ var SocketIO = require('socket.io').listen(global.server);
// BEGIN: API calls (todo: organize)
socket.on('user.create', function(data) {
- modules.user.create(data.username, data.password);
+ modules.user.create(data.username, data.password, data.email);
});
socket.on('user.exists', function(data) {
@@ -40,7 +40,11 @@ var SocketIO = require('socket.io').listen(global.server);
socket.on('user.login', function(data) {
modules.user.login(data);
- });
+ });
+
+ socket.on('user.email.exists', function(data) {
+ modules.user.email.exists(data.email);
+ });
});
}(SocketIO));