[TASK] Minor api fixes.
Altered whitespace, comments and replaced "err" with "error" in JSON responses.
This commit is contained in:
parent
0c0aacd4c3
commit
9e154221a9
2
app.js
2
app.js
|
@ -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();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -43,13 +43,13 @@ var constructor = function(db) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//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!"
|
||||||
|
|
|
@ -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;
|
||||||
|
|
Loading…
Reference in New Issue