File: Token.pm

package info (click to toggle)
libcatalyst-controller-html-formfu-perl 2.04-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 408 kB
  • sloc: perl: 960; makefile: 6
file content (37 lines) | stat: -rw-r--r-- 871 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package TestApp::Controller::Token;

use strict;
use warnings;
use Data::Dumper;
use base 'Catalyst::Controller::HTML::FormFu';

__PACKAGE__->config( { 'Controller::HTML::FormFu' => { request_token_enable => 1 } } );

sub token : Chained : CaptureArgs(0) {
    my ( $self, $c ) = @_;
    $c->stash->{template} = 'form.tt';
}

sub form : Chained('token') : Args(0) : Form {
    my ( $self, $c ) = @_;

    my $form = $c->stash->{form};

    $form->elements( [ { name => 'basic_form', constraint => ['Required'] }, { type => "Submit" } ] );
    $form->process( $c->req );
    if ( $form->submitted_and_valid ) {
        $c->res->body("VALID");
    }
}

sub dump_session : Local {
    my ( $self, $c ) = @_;
    $c->res->body( Dumper $c->session );
}

sub count_token : Local {
    my ( $self, $c ) = @_;
    $c->res->body( scalar @{ $c->session->{__token} || [] } );
}

1;