You can always call the run modes directly by their method names in CGI::Application.
sub rm2_method { my $self = shift; my $username = $self->query->param('user'); my $password = $self->query->param('pass'); return $self->rm1_method() unless defined $username and defined $pas +sword; $self->authenticate() ? $self->rm4_method() : $self->rm3_method(); }
This way, the get_current_runmode() will always return 'rm2' no matter in what method you are in. To change the current runmode as well you'll use the forward plugin.
use CGI::Application::Plugin::Forward; sub rm2_method { my $self = shift; my $username = $self->query->param('user'); my $password = $self->query->param('pass'); return $self->rm1_method() unless defined $username and defined $pas +sword; $self->authenticate() ? $self->forward(rm4') : $self->forward('rm3') +; }
First, the get_current_runmode method always returns the new runmode you forward to. If it's authenticated then you get 'rm4', for example. Second, you don't have to remember the method name of that runmode.

But for me, I won't provide rm3 and rm4. I would probably just use the first approach, by calling other methods (not runmode methods) according to the authentication result. Speaking of which, I would just probably using the authentication plugin.

You can also find numerous discussions from super search (don't forget to click the Search button).


Open source softwares? Share and enjoy. Make profit from them if you can. Yet, share and enjoy!


In reply to Re: CGI::Application trouble understanding it. by naikonta
in thread CGI::Application trouble understanding it. by SteveS832001

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.