send 404 and error message in api_method user.js

v1.18.x
Baris Soner Usakli 12 years ago
parent 575b7f0ecc
commit b146445db1

@ -17,7 +17,7 @@ var user = require('./../user.js'),
if(data) {
res.send(data);
} else {
res.send("User doesn't exist!");
res.json(404, {error:"User doesn't exist!"});
}
});
@ -229,16 +229,29 @@ var user = require('./../user.js'),
if(!req.user)
return res.redirect('/403');
user.get_uid_by_userslug(req.params.userslug, function(uid) {
if(!uid) {
res.redirect('/404');
return;
}
res.send(app.build_header(res) + app.create_route('users/'+req.params.userslug+'/following','following') + templates['footer']);
});
});
app.get('/users/:userslug/followers', function(req, res) {
if(!req.user)
return res.redirect('/403');
user.get_uid_by_userslug(req.params.userslug, function(uid) {
if(!uid) {
res.redirect('/404');
return;
}
res.send(app.build_header(res) + app.create_route('users/'+req.params.userslug+'/followers','followers') + templates['footer']);
});
});
function api_method(req, res) {
@ -277,7 +290,7 @@ var user = require('./../user.js'),
});
});
} else {
res.json(null);
res.json(404, { error: 'User not found!' }) ;
}
});
}
@ -293,7 +306,7 @@ var user = require('./../user.js'),
});
} else {
res.json(null);
res.json(404, { error: 'User not found!' }) ;
}
});
}
@ -307,7 +320,7 @@ var user = require('./../user.js'),
res.json(userData);
});
} else {
res.json(null);
res.json(404, { error: 'User not found!' }) ;
}
});
}

Loading…
Cancel
Save