[TASK] Minor api fixes.

Altered whitespace, comments and replaced "err" with "error"
in JSON responses.
This commit is contained in:
Jan Philipp Timme 2013-09-17 15:38:38 +02:00
parent 0c0aacd4c3
commit 9e154221a9
3 changed files with 7 additions and 7 deletions

2
app.js
View File

@ -60,7 +60,7 @@ app.use(function(req, res, next) {
"lastActivity": new Date().toString() "lastActivity": new Date().toString()
}; };
} }
console.log(["Session Data", req.session.data]); //console.log(["Session Data", req.session.data]);
next(); next();
}); });

View File

@ -44,12 +44,12 @@ var constructor = function(db) {
} }
//check if user exists //check if user exists
db.get(params.username, function(err, doc) { db.get(params.username, function(err, doc) {
console.log(["dbgetuser", arguments]);
if(!err && doc.type == "user") { if(!err && doc.type == "user") {
var userDocument = doc; var userDocument = doc;
//user exists, verify password //user exists, verify password
scrypt.verifyHash(userDocument.auth, params.password, function(err, match) { scrypt.verifyHash(userDocument.auth, params.password, function(err, match) {
if(err || match == false) { if(err || match == false) {
//password not correct
res.send(200, JSON.stringify({ res.send(200, JSON.stringify({
"success": false, "success": false,
"error": "Invalid login credentials!" "error": "Invalid login credentials!"

View File

@ -67,7 +67,7 @@ var constructor = function(db) {
if(req.session.data.login == false) { if(req.session.data.login == false) {
res.send(200, JSON.stringify({ res.send(200, JSON.stringify({
"success": false, "success": false,
"err": "You are not logged in!" "error": "You are not logged in!"
})); }));
return; return;
} }
@ -85,7 +85,7 @@ var constructor = function(db) {
console.log(err); console.log(err);
res.send(200, JSON.stringify({ res.send(200, JSON.stringify({
"success": false, "success": false,
"err": "Something went wrong updating the user document!" "error": "Something went wrong updating the user document!"
})); }));
} else { } else {
db.get(req.session.data.user._id, function(err, result) { db.get(req.session.data.user._id, function(err, result) {
@ -93,7 +93,7 @@ var constructor = function(db) {
console.log(err); console.log(err);
res.send(200, JSON.stringify({ res.send(200, JSON.stringify({
"success": false, "success": false,
"err": "Something went wrong re-reading the user document!" "error": "Something went wrong re-reading the user document!"
})); }));
} else { } else {
req.session.data.user = result; req.session.data.user = result;