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