Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- showVideo: function(req, res) {
- // Find the video to play
- Video.findOne({
- id: +req.param('id')
- }).exec(function (err, foundVideo){
- // If not logged in
- if (!req.session.userId) {
- return res.view('show-video', {
- me: null,
- video: foundVideo,
- tutorialId: req.param('tutorialId')
- });
- }
- // If logged in...
- User.findOne({
- id: +req.session.userId
- }).exec(function (err, foundUser) {
- if (err) {
- return res.negotiate(err);
- }
- if (!foundUser) {
- sails.log.verbose('Session refers to a user who no longer exists- did you delete a user, then try to refresh the page with an open tab logged-in as that user?');
- return res.view('show-video', {
- me: null,
- video: foundVideo,
- tutorialId: req.param('tutorialId')
- });
- }
- return res.view('show-video', {
- me: {
- username: foundUser.username,
- gravatarURL: foundUser.gravatarURL,
- admin: foundUser.admin
- },
- video: foundVideo,
- tutorialId: req.param('tutorialId')
- });
- });
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement