[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cgiapp] authentication -- is this the best way to do it?


In my app using CGI::Application::Plugin::Session, I want the basic view
to be accessible to everyone and other runmodes accessible only to people
who login.  So I have a cgi_prerun function which looks like this:

sub cgiapp_prerun()
{
  my ($self, $runmode) = @_;

  delete $self->{newrunmode} if defined $self->{newrunmode};

  unless ($self->session->param('~logged_in'))
  {
    if (defined $self->query->param('password') &&
      $self->query->param('password') eq $self->param('password'))
    {
      $self->session->param('~logged_in', 1);
    }
    else
    {
      unless ($runmode eq 'login' || $runmode eq 'logout' ||
        $runmode eq 'view')
      {
        $self->{newrunmode} = $runmode;
        $self->prerun_mode('login');
      }
    }
  }
}

The form in the login runmode defines a password text field and a hidden
field called rm which is given the value of $self->{newrunmode} or
$self->start_mode.

This seems to be working well but my question is is there a better way?

-- 
Jaldhar H. Vyas <suppressed>

---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/suppressed/
              http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: suppressed
For additional commands, e-mail: suppressed


Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.