var express = require('express');
var User = require('../schemas/userSchema.js');

var app = express();

app.get('/users', function (req, res, next) {
  res.json({
    "users": [req.user]
  });
});

app.put('/users/:id', function (req, res, next) {
  User.findById(req.params.id).exec().then(function (user) {
    user.projects = req.body.user.projects;
    user.save();

    res.json({
      "user": user
    });
  }, next);
});

module.exports = app;
@@ -144,16 +144,49 @@
 next) %7B%0A
+  if (req.isAuthenticated()) %7B%0A  
   res.js
@@ -186,24 +186,26 @@
  res.json(%7B%0A
+  
     %22users%22:
@@ -220,68 +220,263 @@
 er%5D%0A
+  
   %7D);%0A
-%7D);%0A%0Aapp.put('/users/:id', function (req, res, next) %7B
+  %7D else %7B%0A    res.json(%7B%0A      %22users%22: %5B%7B%0A        _id: %22anonymous user%22%0A      %7D%5D%0A    %7D)%0A  %7D%0A%7D);%0A%0Aapp.put('/users/:id', function (req, res, next) %7B%0A  if (!req.isAuthenticated()) %7B%0A    res.send(401, 'You must be logged in to join a project');%0A  %7D%0A
 %0A  U

Create the anonymous user server side instead