Date: 05/04/01
- Next message: Philip Strnad: "Re: Sv: [phplib] occasional problem with authentication"
- Previous message: Eric Ries: "[phplib] CT_Freenet"
- In reply to: darcy w. christ: "[phplib] login before logout"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Fri, 04 May 2001 15:41:02 -0400, darcy w. christ wrote:
>
> hi,
>
> does anyone have a good approach to the login before logout problem.
> What i mean is that i have a logout page, which has a page_open for both
> session and auth. i need the auth, obviously so that i can destroy the
> auth object. However, i ocaasionally logout after my auth has been
> terminated because i've gone past my lifetime. So, when i try to
> logout, it first asks me to log in. Not very user friendly. Anyway, i
> suppose i need to do a test to see if i am in fact logged in, before
> trying to log out. i'm just not sure how to approach this problem. Has
> anyone resolved this. i appreciate the suggestions.
>
> --
> ~darcy w. christ
> Elegant Communications Inc.
> 416.362.9772 x222 | 416.362.8324 fax
I use the following hack of the page_open() function. It's a bit --
I'd prefer page_open() not to need knowledge of the
$auth->is_authenticated(). However, it does allow me to use the auth
feature on pages that do not require a login. To create such a page,
make sure that you set a global variable $login_not_required to true
BEFORE you call page_open().
I suppose an alternate (and cleaner) method would subclass your auth
class so that start() does nothing but call $auth->is_authenticated().
I stopped experimenting when things work, not when they became clean.
page_open() is defined in page.inc.
-- John Mandeville mandevil at usc dot edufunction page_open($feature) { global $_PHPLIB; global $login_not_required;
# enable sess and all dependent features. if (isset($feature["sess"])) { global $sess; $sess = new $feature["sess"]; $sess->start();
# the auth feature depends on sess if (isset($feature["auth"])) { global $auth;
if (!isset($auth)) { $auth = new $feature["auth"]; } if ( $login_not_required ) { $auth->is_authenticated(); } else { $auth->start(); } if ( ! $sess->is_registered( 'auth' ) ) { $sess->register( 'auth' ); }
# the perm feature depends on auth and sess if (isset($feature["perm"])) { global $perm;
if (!isset($perm)) { $perm = new $feature["perm"]; } }
# the user feature depends on auth and sess if (isset($feature["user"])) { global $user;
if (!isset($user)) { $user = new $feature["user"]; } $user->start($auth->auth["uid"]); } }
## Load the auto_init-File, if one is specified. if (($sess->auto_init != "") && ($sess->in == "")) { $sess->in = 1; include($_PHPLIB["libdir"] . $sess->auto_init); if ($sess->secure_auto_init != "") { $sess->freeze(); } } } }
-- John Mandeville mandevil <email protected>
--------------------------------------------------------------------- To unsubscribe, e-mail: phplib-unsubscribe <email protected> For additional commands, e-mail: phplib-help <email protected>
- Next message: Philip Strnad: "Re: Sv: [phplib] occasional problem with authentication"
- Previous message: Eric Ries: "[phplib] CT_Freenet"
- In reply to: darcy w. christ: "[phplib] login before logout"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

