isAdmin default value = false.
This commit is contained in:
		| @@ -78,9 +78,10 @@ const allWinners = (req, res) => { | |||||||
|  |  | ||||||
| const winnerById = (req, res) => { | const winnerById = (req, res) => { | ||||||
|   const { id } = req.params; |   const { id } = req.params; | ||||||
|  |   const isAdmin = req.isAuthenticated(); | ||||||
|  |  | ||||||
|   return lotteryRepository |   return lotteryRepository | ||||||
|     .winnerById(id) |     .winnerById(id, isAdmin) | ||||||
|     .then(winner => |     .then(winner => | ||||||
|       res.send({ |       res.send({ | ||||||
|         winner, |         winner, | ||||||
| @@ -98,7 +99,7 @@ const winnerById = (req, res) => { | |||||||
| }; | }; | ||||||
|  |  | ||||||
| const deleteWinnerById = (req, res) => { | const deleteWinnerById = (req, res) => { | ||||||
|   const isAdmin = req.isAuthenticated() || true; |   const isAdmin = req.isAuthenticated(); | ||||||
|   const { id } = req.params; |   const { id } = req.params; | ||||||
|  |  | ||||||
|   return lotteryRepository |   return lotteryRepository | ||||||
|   | |||||||
| @@ -71,7 +71,7 @@ const redactWinnerInfoMapper = winner => { | |||||||
|   }; |   }; | ||||||
| }; | }; | ||||||
|  |  | ||||||
| const allAttendees = isAdmin => { | const allAttendees = (isAdmin = false) => { | ||||||
|   if (!isAdmin) { |   if (!isAdmin) { | ||||||
|     return Attendee.find().then(attendees => attendees.map(redactAttendeeInfoMapper)); |     return Attendee.find().then(attendees => attendees.map(redactAttendeeInfoMapper)); | ||||||
|   } else { |   } else { | ||||||
| @@ -101,8 +101,6 @@ const updateAttendeeById = (id, updateModel) => { | |||||||
|       throw new UserNotFound(); |       throw new UserNotFound(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     console.log(updateModel); |  | ||||||
|  |  | ||||||
|     const updatedAttendee = { |     const updatedAttendee = { | ||||||
|       name: updateModel.name != null ? updateModel.name : attendee.name, |       name: updateModel.name != null ? updateModel.name : attendee.name, | ||||||
|       green: updateModel.green != null ? updateModel.green : attendee.green, |       green: updateModel.green != null ? updateModel.green : attendee.green, | ||||||
| @@ -113,8 +111,6 @@ const updateAttendeeById = (id, updateModel) => { | |||||||
|       winner: updateModel.winner != null ? updateModel.winner : attendee.winner |       winner: updateModel.winner != null ? updateModel.winner : attendee.winner | ||||||
|     }; |     }; | ||||||
|  |  | ||||||
|     console.log(updatedAttendee); |  | ||||||
|  |  | ||||||
|     return Attendee.updateOne({ _id: id }, updatedAttendee).then(_ => updatedAttendee); |     return Attendee.updateOne({ _id: id }, updatedAttendee).then(_ => updatedAttendee); | ||||||
|   }); |   }); | ||||||
| }; | }; | ||||||
| @@ -211,7 +207,7 @@ const allWinners = (isAdmin = false) => { | |||||||
|   } |   } | ||||||
| }; | }; | ||||||
|  |  | ||||||
| const winnerById = (id, isAdmin) => { | const winnerById = (id, isAdmin = false) => { | ||||||
|   return VirtualWinner.findOne({ _id: id }).then(winner => { |   return VirtualWinner.findOne({ _id: id }).then(winner => { | ||||||
|     if (winner == null) { |     if (winner == null) { | ||||||
|       throw new WinnerNotFound(); |       throw new WinnerNotFound(); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user