Fixed potential bug in realtime startConnection and bugs in note findOrNewNote, response showNote

This commit is contained in:
Cheng-Han, Wu
2016-01-20 23:20:50 -06:00
parent 50805f3540
commit 16dcd27b78
3 changed files with 16 additions and 9 deletions

View File

@@ -175,15 +175,15 @@ function showNote(req, res, next) {
return response.errorNotFound(res);
}
}
Note.findNote(noteId, function (err, note) {
if (err || !note) {
db.readFromDB(noteId, function (err, data) {
if (err) {
return response.errorNotFound(res);
}
db.readFromDB(note.id, function (err, data) {
if (err) {
var notedata = data.rows[0];
Note.findOrNewNote(noteId, notedata.owner, function (err, note) {
if (err || !note) {
return response.errorNotFound(res);
}
var notedata = data.rows[0];
//check view permission
if (note.permission == 'private') {
if (!req.isAuthenticated() || notedata.owner != req.user._id)