add: check associated when voting on polls

This commit is contained in:
trisua 2025-06-06 15:57:31 -04:00
parent f4630d4464
commit a9845fbd67
2 changed files with 15 additions and 1 deletions

View file

@ -129,7 +129,9 @@
res.message,
]);
window.location.href = `/post/${id}`;
if (res.ok) {
window.location.href = `/post/${id}`;
}
});
});

View file

@ -356,6 +356,18 @@ pub async fn vote_request(
Err(e) => return Json(e.into()),
};
// check associated accounts for prior votes
for id in user.associated {
if data.get_pollvote_by_owner_poll(id, poll.id).await.is_ok() {
return Json(
Error::MiscError(
"You've already voted on this poll on a different account".to_string(),
)
.into(),
);
}
}
// ...
match data
.create_pollvote(PollVote::new(user.id, poll.id, req.option))