[cgiapp] C::A::P::Auth retry

P Kishor punk.kish at gmail.com
Sun Jun 7 13:44:30 EDT 2009


I have a couple of Authentication related queries I can't figure out on my own.

1. I have created a custom login page so when the user wants to view a
protected page, my login form is presented. If the user succeeds in
logging in, the protected page is presented correctly. However, if the
user fails, they user is redirected to the default runmode, and not
back to the login page. Of course, if I remove my custom login page,
then the module provided login page works fine -- that is, on failure,
it is re-presented to the user along with a message stating that the
attempt failed and the attempt number. How do I make my custom login
page be presented again on failure to login?

In C::A::Dispatch

CGI::Application::Dispatch->dispatch(
    table => [
        welcome => { app => $App, rm => 'welcome' },
        view => { app => $App, rm => 'view' },
        login => { app => $App, rm => 'login' },
    ],
);

In $App

# Configure the session once during the init stage
sub cgiapp_init {
    my $self = shift;

    App->authen->config(
        DRIVER => [ 'Generic', { user1 => '123' } ],
        STORE => 'Session',
        LOGIN_RUNMODE  => 'login',
        LOGOUT_RUNMODE => 'welcome',
        POST_LOGIN_RUNMODE => 'view'
    );

    App->authen->protected_runmodes('view');
}

# Run at startup
sub setup {
    my $self = shift;

    $self->start_mode("welcome");
    $self->mode_param(param => 'rm');
    $self->run_modes(
        welcome => 'welcome',
        view    => 'view',
        login   => 'login',
    );
}

sub login {
    my $self = shift;
    my $tmpl = $self->load_tmpl('login.tmpl');
    return $tmpl->output;
}

2. How do I allow for when the user has forgotten username/password,
or for creating a new username/password? There seem to be references
to this functionality in the module, but no documentation or tutorial
that I can find.

Any guidance will be much appreciated.


-- 
Puneet Kishor http://www.punkish.org/
Carbon Model http://carbonmodel.org/
Charter Member, Open Source Geospatial Foundation http://www.osgeo.org/
Science Commons Fellow, Geospatial Data http://sciencecommons.org
Nelson Institute, UW-Madison http://www.nelson.wisc.edu/
-----------------------------------------------------------------------
collaborate, communicate, compete
=======================================================================
Sent from Madison, WI, United States


More information about the cgiapp mailing list