[TASK] Store user document in session data.

This commit is contained in:
Jan Philipp Timme 2013-09-16 21:16:33 +02:00
parent d4830be76b
commit b121210533
1 changed files with 3 additions and 1 deletions

View File

@ -46,8 +46,9 @@ var constructor = function(db) {
db.get(params.username, function (err, doc) {
console.log(["dbgetuser", arguments]);
if(!err && doc.type == "user") {
var userDocument = doc;
//user exists, verify password
scrypt.verifyHash(doc.auth, params.password, function(err, match) {
scrypt.verifyHash(userDocument.auth, params.password, function(err, match) {
if(err || match == false) {
res.send(200, JSON.stringify({
"success": false,
@ -56,6 +57,7 @@ var constructor = function(db) {
return;
}
if(!err && match == true) {
req.session.data.user = userDocument;
req.session.data.login = true;
req.session.data.lastActivity = new Date().toString();
res.send(200, JSON.stringify({