get for add page works
[scpubgit/Commentry.git] / lib / App / Commentry / CaptchaHandler / Fixed.pm
CommitLineData
2fc10229 1package App::Commentry::CaptchaHandler::Fixed;
2
3use Moo;
4
5has challenge => (is => 'ro', default => sub {
6 q{What is mst the chainsaw wielder's weapon of choice?}
7});
8
9has field_name => (is => 'ro', default => sub { 'captcha_response' });
10
11has response_match => (is => 'ro', default => sub { qr/(?i:chainsaw)/ });
12
13sub challenge_html {
14 my ($self) = @_;
15
16 my $field_name = $self->field_name;
17
18 use HTML::Tags;
19 join '', HTML::Tags::to_html_string(
20 <p>, $self->challenge, </p>, "\n",
21 <input name="${field_name}" />, "\n",
22 );
23}
24
25sub check_response {
26 my ($self, $params) = @_;
27 my $match = $self->response_match;
28 !!($params->{$self->field_name} =~ /$match/);
29}
30
311;