Revert "Add CAPTCHA for flag_thread"

This reverts commit ce6d405b1d.
This commit is contained in:
swag 2023-06-17 18:24:55 -04:00
parent 9ae401f86d
commit 11d2f80524
3 changed files with 10 additions and 40 deletions

View File

@ -151,28 +151,14 @@ sub bump($self) {
sub flag($self) { sub flag($self) {
my $thread_id = $self->param('thread_id'); my $thread_id = $self->param('thread_id');
my $v = $self->validation; my $redirect_url = $self->url_for('threads_list')->fragment('info')->to_abs;
$v->optional(captcha => 'trim')->size(4, 4)->like(qr/flag/i);
if ($v->is_valid) {
my $redirect_url =
$self->url_for('threads_list')->fragment('info')->to_abs;
$self->thread->flag($thread_id); $self->thread->flag($thread_id);
$self->flash( $self->flash(
info => "Thread #$thread_id has been flagged for moderator. 🚩" info => "Thread #$thread_id has been flagged for moderator. 🚩"
); );
return $self->redirect_to($redirect_url); $self->redirect_to($redirect_url);
}
elsif ($v->has_error) {
$self->stash(status => 400)
}
$self->stash(thread_id => $thread_id);
return $self->render;
} }
1; 1;

View File

@ -98,8 +98,9 @@ subtest 'Flagging thread', sub {
->element_exists('a[href*="flag"]') ->element_exists('a[href*="flag"]')
->text_like(h2 => qr/Thread #1/); ->text_like(h2 => qr/Thread #1/);
$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); ->element_exists('p[class="stash-with-info"]')
->text_like(p => qr/Thread #1 has been flagged/);
}; };
done_testing; done_testing;

View File

@ -1,17 +0,0 @@
% layout 'default';
% title $thread_id ? "Flag Thread #$thread_id" : '?';
<h2 class="page-title"><%= title %></h2>
<% if ($thread_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">Flag</button>
</fieldset>
</form>
<% } =%>