Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
use POST for CSRF protection example
  • Loading branch information
kraih committed Dec 3, 2013
1 parent 72d5f1e commit 1f5d479
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/Mojolicious/Guides/Rendering.pod
Expand Up @@ -753,13 +753,13 @@ validate it with L<Mojolicious::Validator::Validation/"csrf_protect">.

use Mojolicious::Lite;

get '/' => sub {
my $self = shift;
get '/' => sub { shift->render('target') };

my $validation = $self->validation;
return $self->render unless $validation->has_data;
post '/' => sub {
my $self = shift;

# Check CSRF token
my $validation = $self->validation;
return $self->render(text => 'Bad CSRF token!', status => 403)
if $validation->csrf_protect->has_error('csrf_token');

Expand Down

0 comments on commit 1f5d479

Please sign in to comment.