[TASK] Store user document in session data.
This commit is contained in:
parent
d4830be76b
commit
b121210533
@ -46,8 +46,9 @@ var constructor = function(db) {
|
|||||||
db.get(params.username, function (err, doc) {
|
db.get(params.username, function (err, doc) {
|
||||||
console.log(["dbgetuser", arguments]);
|
console.log(["dbgetuser", arguments]);
|
||||||
if(!err && doc.type == "user") {
|
if(!err && doc.type == "user") {
|
||||||
|
var userDocument = doc;
|
||||||
//user exists, verify password
|
//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) {
|
if(err || match == false) {
|
||||||
res.send(200, JSON.stringify({
|
res.send(200, JSON.stringify({
|
||||||
"success": false,
|
"success": false,
|
||||||
@ -56,6 +57,7 @@ var constructor = function(db) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(!err && match == true) {
|
if(!err && match == true) {
|
||||||
|
req.session.data.user = userDocument;
|
||||||
req.session.data.login = true;
|
req.session.data.login = true;
|
||||||
req.session.data.lastActivity = new Date().toString();
|
req.session.data.lastActivity = new Date().toString();
|
||||||
res.send(200, JSON.stringify({
|
res.send(200, JSON.stringify({
|
||||||
|
Loading…
Reference in New Issue
Block a user