summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2020-07-19 10:27:28 +0200
committerYorhel <git@yorhel.nl>2020-07-19 10:28:02 +0200
commitdcb875dd1ab06dd89006d01bf6a637b626753b80 (patch)
tree0049739b94868f31c9269f27694833b0093767c3 /lib
parentc6aab8ce3d9141a0977a3c42f19a3d901bcd60c3 (diff)
Image::Vote: Fix allowing users to change their vote
Broken in 8939317270f5facdd127c1b7640842a02a76e93c
Diffstat (limited to 'lib')
-rw-r--r--lib/VNWeb/Images/Lib.pm2
-rw-r--r--lib/VNWeb/Images/Vote.pm2
2 files changed, 2 insertions, 2 deletions
diff --git a/lib/VNWeb/Images/Lib.pm b/lib/VNWeb/Images/Lib.pm
index bee2086c..adf9186a 100644
--- a/lib/VNWeb/Images/Lib.pm
+++ b/lib/VNWeb/Images/Lib.pm
@@ -46,7 +46,6 @@ sub enrich_image {
}, $l;
for(@$l) {
- $_->{token} = $canvote || ($_->{votecount} == 0 && auth->permImgvote) ? auth->csrftoken(0, "imgvote-$_->{id}") : undef;
$_->{entry} = $_->{entry_id} ? { id => $_->{entry_id}, title => $_->{entry_title} } : undef;
delete $_->{entry_id};
delete $_->{entry_title};
@@ -54,6 +53,7 @@ sub enrich_image {
$v->{user} = xml_string sub { user_ $v }; # Easier than duplicating user_() in Elm
delete $v->{$_} for grep /^user_/, keys %$v;
}
+ $_->{token} = ($_->{votecount} == 0 && auth->permImgvote) || (ref $canvote eq 'CODE' ? $canvote->($_) : $canvote) ? auth->csrftoken(0, "imgvote-$_->{id}") : undef;
}
}
diff --git a/lib/VNWeb/Images/Vote.pm b/lib/VNWeb/Images/Vote.pm
index 18b4bb2a..e8a8b2f1 100644
--- a/lib/VNWeb/Images/Vote.pm
+++ b/lib/VNWeb/Images/Vote.pm
@@ -125,7 +125,7 @@ TUWF::get qr{/img/$RE{imgid}}, sub {
my $id = tuwf->capture('id');
my $l = [{ id => $id }];
- enrich_image defined($l->[0]{my_sexual}) || auth->permImgmod(), $l;
+ enrich_image auth->permImgmod() || sub { defined $_[0]{my_sexual} }, $l;
return tuwf->resNotFound if !defined $l->[0]{width};
framework_ title => "Image flagging for $id", sub {