Make CAPTCHA more random
This commit is contained in:
parent
4420202d5f
commit
f50bcce74e
|
@ -5,9 +5,12 @@
|
|||
|
||||
use Mojolicious::Lite -signatures;
|
||||
use Mojo::Pg;
|
||||
use List::Util qw{shuffle};
|
||||
use Data::Dumper; # Uncomment for debugging
|
||||
|
||||
# Load the model
|
||||
use lib 'lib';
|
||||
use GuestbookNg::Model::Message;
|
||||
use Data::Dumper; # Uncomment for debugging
|
||||
|
||||
# Plugins
|
||||
plugin 'Config';
|
||||
|
@ -67,7 +70,20 @@ any [qw{GET POST}], '/sign' => sub ($c) {
|
|||
$c->redirect_to('index');
|
||||
}
|
||||
else {
|
||||
$c->render()
|
||||
my @answers = shuffle(0, 'false', undef);
|
||||
my $right_answer_label = 'I\'m ready to sign (choose this one)';
|
||||
my @wrong_answer_labels = shuffle(
|
||||
'I don\'t want to sign (wrong answer)',
|
||||
'This is spam/I\'m a bot, do not sign'
|
||||
);
|
||||
|
||||
$c->stash(
|
||||
answers => \@answers,
|
||||
right_answer_label => $right_answer_label,
|
||||
wrong_answer_labels => \@wrong_answer_labels
|
||||
);
|
||||
|
||||
$c->render();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
</center>
|
||||
</div>
|
||||
<div class="inner">
|
||||
<%= content %>
|
||||
<%= content =%>
|
||||
</div>
|
||||
<div class="outer">
|
||||
<footer>
|
||||
|
|
|
@ -16,12 +16,11 @@
|
|||
</div>
|
||||
<h3>SwaggCAPTCHA™</h3>
|
||||
<div class="captcha field">
|
||||
<%= radio_button answer => 0 %>
|
||||
<%= label_for answer => 'I don\'t want to sign (wrong answer)' %>
|
||||
<%= radio_button answer => 'false' %>
|
||||
<%= label_for answer => 'I\'m ready to sign (choose this one)' %>
|
||||
<%= radio_button answer => undef %>
|
||||
<%= label_for answer => 'This is spam/I\'m a bot, do not sign' %>
|
||||
<% for my $answer (@$answers) { =%>
|
||||
<%= radio_button answer => $answer %>
|
||||
<%= label_for answer =>
|
||||
$answer ? $right_answer_label : pop @$wrong_answer_labels %>
|
||||
<% } =%>
|
||||
</div>
|
||||
<%= submit_button 'Sign it', class => 'win95button' %>
|
||||
</form>
|
||||
|
|
Loading…
Reference in a new issue