prevent users from being able to send more than one typed poll answer

This commit is contained in:
Ramón Souza 2021-11-25 17:51:36 +00:00
parent db77e38104
commit 30f6a642dd

View File

@ -18,6 +18,21 @@ export default function publishTypedVote(id, pollAnswer) {
check(pollAnswer, String);
check(id, String);
const allowedToVote = Polls.findOne({
id,
users: { $in: [requesterUserId] },
meetingId,
}, {
fields: {
users: 1,
},
});
if (!allowedToVote) {
Logger.info(`Poll User={${requesterUserId}} has already voted in PollId={${id}}`);
return null;
}
const activePoll = Polls.findOne({ meetingId, id }, {
fields: {
answers: 1,