From 5ebbb198e9228212a078b45bc896b3e7f8349b95 Mon Sep 17 00:00:00 2001 From: Andrew McMillan Date: Fri, 24 Sep 2010 23:33:43 +1200 Subject: [PATCH] Allow basic auth to supply credentials as well. --- inc/DAViCalSession.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/inc/DAViCalSession.php b/inc/DAViCalSession.php index c7635fa5..909e7860 100644 --- a/inc/DAViCalSession.php +++ b/inc/DAViCalSession.php @@ -117,6 +117,16 @@ class DAViCalSession extends Session } if ( isset($c->restrict_admin_roles) && $roles == '' ) $roles = $c->restrict_admin_roles; if ( $this->logged_in && $roles == '' ) return; + + /** + * We allow basic auth to apply also, if present, though we check everything else first... + */ + if ( !$this->logged_in && $_SERVER['PHP_AUTH_USER'] != "" && $_SERVER['PHP_AUTH_PW'] != "" && ! $_COOKIE['NoAutoLogin'] ) { + if ( $this->Login($_SERVER['PHP_AUTH_USER'],$_SERVER['PHP_AUTH_PW'],true)) { + setcookie('NoAutoLogin',1,0); + return; + } + } if ( ! $this->logged_in ) { $c->messages[] = i18n('You must log in to use this system.'); include_once('page-header.php');