File: template.cgi

package info (click to toggle)
libcgi-application-plugin-authentication-perl 0.25%2B~cs0.5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,560 kB
  • sloc: perl: 11,362; makefile: 29; javascript: 6
file content (77 lines) | stat: -rwxr-xr-x 2,192 bytes parent folder | download | duplicates (6)
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/usr/bin/perl 

#
# Sample application [Templates]
#
# This example is a bit more realistic than the sample.cgi and basic.cgi.
# It is intended to show how you can control the style of the Basic login form.
# You need to copy the templates and the contents of the httpdocs
# to their appropriate places for you server. 
# Unless you change the .cgi script to use a local copy,
# you will also need access to the internet so the script can load
# some javascript files from YUI.
#
# The only valid username/password
# combination is 'test' and '123'.
#

use strict;
use warnings;
use Readonly;

# This bit needs to be modified for the local system.
Readonly my $TEMPLATE_DIR => 'example/templates';

{

    package SampleLogin;

    use base ("CGI::Application::Plugin::HTDot", "CGI::Application");

    use CGI::Application::Plugin::Session;
    use CGI::Application::Plugin::Authentication;
    use CGI::Application::Plugin::AutoRunmode;
    use CGI::Application::Plugin::Authentication::Display::Basic;
    use CGI::Carp qw(fatalsToBrowser);

    my %config = (
        DRIVER         => [ 'Generic', { test => '123' } ],
        STORE          => 'Cookie',
        LOGOUT_RUNMODE => 'one',
        LOGIN_RUNMODE => 'login',
    );
    SampleLogin->authen->config(%config);
    SampleLogin->authen->protected_runmodes('two');

    sub setup {
        my $self = shift;
        $self->start_mode('one');
    }

    sub one : Runmode {
        my $self = shift;
        my $tmpl_obj = $self->load_tmpl('one.tmpl');
        return $tmpl_obj->output;
    }

    sub login : Runmode {
        my $self = shift;
        my $tmpl_obj = $self->load_tmpl('login.tmpl');
        my $display =
        CGI::Application::Plugin::Authentication::Display::Basic->new($self);
        $tmpl_obj->param(login => $display);
        return $tmpl_obj->output;
    }

    sub two : Runmode {
        my $self = shift;
        my $tmpl_obj = $self->load_tmpl('two.tmpl');
        my $display =
        CGI::Application::Plugin::Authentication::Display::Basic->new($self);
        $tmpl_obj->param(login => $display);
        return $tmpl_obj->output;
    }
}

SampleLogin->new(TMPL_PATH=>$TEMPLATE_DIR)->run;