The isMaker controller method ensures that the signed-in user is actually the maker of the game being edited.
mern-vrgame/server/controllers/game.controller.js:
const isMaker = (req, res, next) => { let isMaker = req.game && req.auth && req.game.maker._id == req.auth._id if(!isMaker){ return res.status('403').json({ error: "User is not authorized" }) } next()}
The update method in the game controller will take the existing game details and the form data received in the request body to merge the changes, and save the updated game to the Game collection in the database.
mern-vrgame/server/controllers/game.controller.js:
const update = (req, res) => { let game = req.game game = _.extend(game, req.body) game.updated = Date.now()