Lol,,
I'm an idiot...
sometimes you stare at something so long, you can't see the wood for the
trees..
All I had to do was this..:
sub cgiapp_prerun
{
my $self = shift;
my $form_parameters = $self->query();
my ($session_id, $session) = get_ID($form_parameters);
# If they are not logged in already, and they are not trying to.
# Send them to the login screen so they have to......
unless ($session->param("logged_in"))
{
if (($form_parameters->param('username')) &&
($form_parameters->param('display') ne 'mode_2'))
{
$session->delete ();
$self->prerun_mode('mode_1');
}
}
}
Now I can remove the sub in each runmode that tests for the existance of the
param 'username'.. since if it exists, and the form is not pointed to the
login.. they will get directed there...
Much more logical...
thanks again everyone...
regards
Frank
-----Original Message-----
From: Franki [mailto:[EMAIL PROTECTED]]
Sent: Thursday, 19 December 2002 11:31 PM
To: [EMAIL PROTECTED]
Subject: RE: [cgiapp] cgiapp_prerun (SOLVED !!!)
Hi guys,
I worked out a way to stop two id files beging created by cgiapp_prerun
Its expensive in that it destroys an id it just created if the user hasn't
logged in...
but it works well enough.. and if the user has logged in, then it does
nothing.
sub cgiapp_prerun
{
my $self = shift;
my $form_parameters = $self->query();
my ($session_id, $session) = get_ID($form_parameters);
# If they are not logged in already, and they are not trying to.
# Send them to the login screen so they have to......
unless (($form_parameters->param('username')) ||
($session->param("logged_in")))
{
$session->delete ();
$self->prerun_mode('mode_1');
}
}
Just FYI...
Its not perfect.. someone could call a different run mode and pass it the
parameter "username" to it to escape this..
but i added this, which is called in all non login runmodes:
# Usage:
my $message = check_logged_in($self,$form_parameters, $session);
if ($message)
{
$self->param(message => $message);
$self->param(Session_id => $session_id);
return $self->display_login();
}
######################################
sub check_logged_in
{
my $self = shift;
my $form_parameters = shift;
my $session = shift;
my $message;
if ((!$session->param("logged_in")) ||
($form_parameters->param('username')))
{
$message ='<font color=\'red\'>You must login first!!<br />(attempt
details logged.)</font>';
return $message;
}
}
Thankyou for all the tips..
This list is great.. :-)
rgds
Frank
-----Original Message-----
From: William McKee [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, 18 December 2002 7:33 AM
To: Franki
Cc: [EMAIL PROTECTED]
Subject: Re: [cgiapp] cgiapp_prerun
On 18 Dec 2002 at 6:10, Franki wrote:
> Then it directs to the login runmode, which hasn't been passed the user
> ID.. so it creates another one.. Is there a way to pass the ID from
> cgiapp_prerun to the login runmode??? (I mean appart from a cookie.)
Hi Franki,
Try setting a param in cgiapp_prerun using the following code:
$self->param('user_id', $user_id) ;
Then retrieve this value in your mode_1 sub with this code:
my $user_id = $self->param('user_id');
Good luck,
William
--
Lead Developer
Knowmad Services Inc. || Internet Applications & Database Integration
http://www.knowmad.com
---------------------------------------------------------------------
Web Archive: http://www.mail-archive.com/[email protected]/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
Web Archive: http://www.mail-archive.com/[email protected]/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]