// Set req.user to an empty object so it doesn't throw errors
// later on that it isn't defined.
- req.user = {};
+ req.user = {
+ sanitized: {}
+ };
next();
}
if( schools ) {
// If schools are found, loop through them gathering any courses that are
// associated with them and then render the page with that information.
- res.json({ 'schools' : schools.map(function(school) {
+ res.json({ 'user': user.sanitized, 'schools' : schools.map(function(school) {
return school.sanitized;
})})
} else {
// If no schools have been found, display none
//res.render( 'schools', { 'schools' : [] } );
- res.json({ 'schools' : [] });
+ res.json({ 'schools' : [] , 'user': user.sanitized });
}
});
});
// This tells async (the module) that each iteration of forEach is
// done and will continue to call the rest until they have all been
// completed, at which time the last function below will be called.
- res.json({ 'school': sanitizedSchool })
+ res.json({ 'school': sanitizedSchool, 'user': user.sanitized })
});
});
});
// Get course instructor information using their id
User.findById( course.instructor, function( err, instructor ) {
// Render course and lectures
- res.json( { 'course' : course.sanitized, 'instructor': instructor.sanitized, 'subscribed' : subscribed, 'lectures' : lectures.map(function(lecture) { return lecture.sanitized })} );
+ res.json( { 'user': req.user.sanitized, 'course' : course.sanitized, 'instructor': instructor.sanitized, 'subscribed' : subscribed, 'lectures' : lectures.map(function(lecture) { return lecture.sanitized })} );
})
});
});
'lecture' : lecture.sanitized,
'course' : course.sanitized,
'instructor' : instructor.sanitized,
+ 'user' : req.user.sanitized,
'notes' : notes.map(function(note) {
return note.sanitized;
})
if ( err ) {
res.json( {status: 'error', message: 'There was a problem gathering the archived courses, please try again later.'} );
} else {
- res.json( { 'subjects' : subjects } );
+ res.json( { 'subjects' : subjects, 'user': req.user.sanitized } );
}
})
})
if ( err ) {
res.json( {status: 'error', message: 'There are no archived courses'} );
} else {
- res.json( { 'courses' : courses, 'subject': req.subject } );
+ res.json( { 'courses' : courses, 'subject': req.subject, 'user': req.user.sanitized } );
}
})
})
if ( err ) {
res.json( {status: 'error', message: 'There are no notes in this course'} );
} else {
- res.json( { 'notes' : notes, 'course' : req.course } );
+ res.json( { 'notes' : notes, 'course' : req.course, 'user': req.user.sanitized } );
}
})
})
if ( err ) {
res.json( {status: 'error', message: 'There is no course for this note'} )
} else {
- res.json( { 'layout' : 'notesLayout', 'note' : note, 'course': course } );
+ res.json( { 'layout' : 'notesLayout', 'note' : note, 'course': course, 'user': req.user.sanitized } );
}
})
}