You set the authentication by stating what runmodes are protected, that is, require login, this is one way to do it, works great for me.

You do it in setup(), or you could do it in a callback- deal with that later.

Check this.. about protected runmodes

You must keep in mind that the examples on that doc, are setting the authen protected runmodes class wide, instead of instance wide. Personally I preffer to do it in the setup() phase or in a callback. Here is a convoluted example..

sub setup { my $self = shift; $self->start_mode('home'); $self->mode_param('rm'); $self->my_authen_config; } # 2 sub my_authen_config { my $self = shift; $self->authen->config( DRIVER => [ 'Generic', sub { $self->my_verify_credentials(@_) }, + ], LOGIN_SESSION_TIMEOUT => $LOGIN_SESSION_TIMEOUT, CREDENTIALS => ['authen_username', 'authen_password' ], STORE => 'Session', LOGIN_RUNMODE => 'login', ); $self->authen->protected_runmodes(qr/^(?!_?log)/); $self->authen; } sub my_verify_credentials { my $self = shift; my ($username,$password)= @_; ($username and $password ) or $self->feedback("Missing username or password.") and return; $self->my_method_for_password_test( $username, $password) or $self->feedback("Wrong username or password.") and return; return $username; }

(keep in mind this code is not fully functional by itself)


In reply to Re: cgi::application authentication by leocharre
in thread cgi::application authentication by neptuneray

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.