add: check associated when voting on polls
This commit is contained in:
parent
f4630d4464
commit
a9845fbd67
2 changed files with 15 additions and 1 deletions
|
@ -129,7 +129,9 @@
|
||||||
res.message,
|
res.message,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
window.location.href = `/post/${id}`;
|
if (res.ok) {
|
||||||
|
window.location.href = `/post/${id}`;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -356,6 +356,18 @@ pub async fn vote_request(
|
||||||
Err(e) => return Json(e.into()),
|
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
|
match data
|
||||||
.create_pollvote(PollVote::new(user.id, poll.id, req.option))
|
.create_pollvote(PollVote::new(user.id, poll.id, req.option))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue