Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

I haven't been using C::A for too terribly long, but so far, it's been a blessing to my web development efforts ;) Your approach to this is not too dissimilar to my own:

My applications have a lot in common, from configuration files to session parameters to application parameters. Typically, when one of my apps needs to handle a login, they simply redirect to my user module as follows:

# Are we logged in? If not, redirect someplace sane! unless(user_is_logged_in()) { $self->param("session")->param("login_redirect", $request->url + . "?mode=modify"); # Redirect! $self->header_type("redirect"); $self->header_props(-url => "/cgi-bin/users.cgi?rm=login"); return "Please wait. . ."; }
Notice the login_redirect param. Login uses this to decide where to send the user upon a successful login.

My login handling code then looks like this:

# Check for username and password my $username = untaint_string($request->param("username")) || ""; my $password = untaint_string($request->param("password")) || ""; # Perform the login? my $page; if($username ne "") { # Log them in! my $check_user = user_login($username, $password); # Check login status if($username eq $check_user) { # Set session parameters $self->param("session")->param("is_logged_in", "Y"); # Where do we redirect upon success? my $redirect = $self->param("session")->param("login_redir +ect"); $redirect = $config{URL_BASE} unless($redirect ne ""); # Redirect! $self->header_type("redirect"); $self->header_props(-url => $redirect); return "Please wait. . ."; } elsif($username eq "INACTIVE") { $self->param("error", "This account is currently inactive. +"); $page = $self->login(); } else { $self->param("error", "Invalid user/password combination. Please enter a ne +w username and password."); $page = $self->login(); } } else { $self->param("error", "Invalid user/password combination. Ple +ase enter a new username and password."); $page = $self->login(); } return $page;
Some of these functions are from my own application code, but you should get the gist of what is going on.

Sorry that I am unable to answer your question with regards to bloat. I'm not the best at profiling an application :(

Hope this helps you somewhat and answers your questions. Feel free to bombard me with your questions.

Good luck!
MrCromeDome


In reply to Re: Structuring multiple CGI::Application modules by MrCromeDome
in thread Structuring multiple CGI::Application modules by Anonymous Monk

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (1)
As of 2024-04-25 04:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found