Revert "captcha for flag_remark"

This reverts commit d749b1a9c8.
This commit is contained in:
swagg boi 2023-06-17 18:22:22 -04:00
parent 4a95a107c5
commit b7494337e8
6 changed files with 16 additions and 47 deletions

View file

@ -1 +0,0 @@
daniel@graymember.5691

View file

@ -64,29 +64,19 @@ sub create($self) {
} }
sub flag($self) { sub flag($self) {
my $remark_id = $self->param('remark_id'); my $remark_id = $self->param('remark_id');
my $v = $self->validation; my $thread_id = $self->remark->thread_id_for($remark_id);
my $redirect_url =
$self->url_for('single_thread', thread_id => $thread_id)
->fragment('info')->to_abs;
$v->optional(captcha => 'trim')->size(4, 4)->like(qr/flag/i);
if ($v->is_valid) { $self->remark->flag($remark_id);
my $thread_id = $self->remark->thread_id_for($remark_id); $self->flash(
my $redirect_url = info => "Remark #$remark_id has been flagged for moderator. 🚩"
$self->url_for('single_thread', thread_id => $thread_id) );
->fragment('info')->to_abs;
$self->remark->flag($remark_id); $self->redirect_to($redirect_url);
$self->flash(
info => "Remark #$remark_id has been flagged for moderator. 🚩"
);
return $self->redirect_to($redirect_url);
}
elsif ($v->has_error) {
$self->stash(status => 400)
}
return $self->render;
} }
1; 1;

View file

@ -157,7 +157,7 @@ sub bump($self) {
$self->stash(status => 400) $self->stash(status => 400)
} }
return $self->render; $self->render;
} }
sub flag($self) { sub flag($self) {

View file

@ -48,10 +48,9 @@ subtest 'Flagging remark', sub {
->element_exists('a[href*="flag"]') ->element_exists('a[href*="flag"]')
->text_like(h2 => qr/Remark #1/); ->text_like(h2 => qr/Remark #1/);
$t->get_ok('/remark/flag/1' )->status_is(200); $t->get_ok('/remark/flag/1')->status_is(200)
$t->get_ok('/remark/flag/65536')->status_is(404); ->element_exists('p[class="stash-with-info"]')
$t->get_ok('/remark/flag/1', form => {captcha => 'flag'})->status_is(200); ->text_like(p => qr/Remark #1 has been flagged/);
$t->get_ok('/remark/flag/1', form => {captcha => 'aaaa'})->status_is(400);
}; };
done_testing; done_testing;

View file

@ -90,8 +90,7 @@ subtest 'Bumping thread', sub {
$t->get_ok('/thread/bump/1' )->status_is(200); $t->get_ok('/thread/bump/1' )->status_is(200);
$t->get_ok('/thread/bump/65536')->status_is(404); $t->get_ok('/thread/bump/65536')->status_is(404);
$t->get_ok('/thread/bump/1', form => {captcha => 'bump'})->status_is(200); $t->get_ok('/thread/bump/1', form => {captcha => 'bump'})->status_is(400);
$t->get_ok('/thread/bump/1', form => {captcha => 'aaaa'})->status_is(400);
}; };
subtest 'Flagging thread', sub { subtest 'Flagging thread', sub {
@ -105,8 +104,7 @@ subtest 'Flagging thread', sub {
$t->get_ok('/thread/flag/1' )->status_is(200); $t->get_ok('/thread/flag/1' )->status_is(200);
$t->get_ok('/thread/flag/65536')->status_is(404); $t->get_ok('/thread/flag/65536')->status_is(404);
$t->get_ok('/thread/flag/1', form => {captcha => 'flag'})->status_is(200); $t->get_ok('/thread/flag/1', form => {captcha => 'flag'})->status_is(400);
$t->get_ok('/thread/flag/1', form => {captcha => 'aaaa'})->status_is(400);
}; };
done_testing; done_testing;

View file

@ -1,17 +0,0 @@
% layout 'default';
% title $remark_id ? "Flag Remark #$remark_id" : '?';
<h2 class="page-title"><%= title %></h2>
<% if ($remark_id) { =%>
<form class="form-body">
<div class="form-field">
<% if (my $error = validation->error('captcha')) { =%>
<p class="field-with-error">Must be between <%= $error->[2] %>
and <%= $error->[3] %> characters.</p>
<% } =%>
<%= label_for captcha => "Enter the word 'flag' to confirm:" %>
<%= text_field captcha => id => 'captcha' %>
</div>
<button type="submit" class="form-button">Confirm</button>
</fieldset>
</form>
<% } =%>