Fix: Better support of login method http

This commit is contained in:
Laurent Destailleur 2008-05-02 01:10:00 +00:00
parent 3d2833996f
commit 98ebbf7571
3 changed files with 96 additions and 79 deletions

View File

@ -14,14 +14,13 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
*/ */
/** /**
\file htdocs/includes/login/functions_http.php \file htdocs/includes/login/functions_http.php
\ingroup core \ingroup core
\brief Authentication functions for HTTP Basic \brief Authentication functions for HTTP Basic
\version $Id$
*/ */

View File

@ -190,7 +190,11 @@ if (! isset($_SESSION["dol_login"]))
// Tests de validation user/mot de passe // Tests de validation user/mot de passe
// Si ok, la variable login sera initialisee // Si ok, la variable login sera initialisee
// Si erreur, on a placera message erreur dans session sous le nom dol_loginmesg // Si erreur, on a placera message erreur dans session sous le nom dol_loginmesg
if ($test && isset($_POST["username"])) $goontestloop=false;
if (isset($_SERVER["REMOTE_USER"]) && in_array('http',$authmode)) $goontestloop=true;
if (isset($_POST["username"])) $goontestloop=true;
if ($test && $goontestloop)
{ {
foreach($authmode as $mode) foreach($authmode as $mode)
{ {
@ -205,7 +209,11 @@ if (! isset($_SESSION["dol_login"]))
$passwordtotest=$_POST["password"]; $passwordtotest=$_POST["password"];
$function='check_user_password_'.$mode; $function='check_user_password_'.$mode;
$login=$function($usertotest,$passwordtotest); $login=$function($usertotest,$passwordtotest);
if ($login) $test=false; if ($login)
{
$test=false;
$conf->authmode=$mode; // This properties is defined only when login
}
} }
else else
{ {
@ -327,6 +335,7 @@ if (! isset($_SESSION["dol_login"]))
// Nouvelle session pour ce login // Nouvelle session pour ce login
$_SESSION["dol_login"]=$user->login; $_SESSION["dol_login"]=$user->login;
$_SESSION["dol_password"]=$user->pass_crypted; $_SESSION["dol_password"]=$user->pass_crypted;
$_SESSION["dol_authmode"]=$conf->authmode;
dolibarr_syslog("This is a new started user session. _SESSION['dol_login']=".$_SESSION["dol_login"].' Session id='.session_id()); dolibarr_syslog("This is a new started user session. _SESSION['dol_login']=".$_SESSION["dol_login"].' Session id='.session_id());
$db->begin(); $db->begin();
@ -901,40 +910,47 @@ function top_menu($head, $title="", $target="")
print $menutop->atarget?(' target="'.$menutop->atarget.'"'):''; print $menutop->atarget?(' target="'.$menutop->atarget.'"'):'';
print '>'.$user->login.'</a>'; print '>'.$user->login.'</a>';
// Lien logout // Lien info
if (! isset($_SERVER["REMOTE_USER"]) || ! $_SERVER["REMOTE_USER"]) $htmltext=''; $text='';
if ($_SESSION["dol_authmode"] != 'forceuser'
&& $_SESSION["dol_authmode"] != 'http')
{ {
$title=$langs->trans("Logout").'<br>'; $htmltext=$langs->trans("Logout").'<br>';
$title.='<br><u>'.$langs->trans("User").'</u>'; $htmltext.="<br>";
$title.='<br><b>'.$langs->trans("Name").'</b>: '.$user->fullname;
$title.='<br><b>'.$langs->trans("Login").'</b>: '.$user->login;
$title.='<br><b>'.$langs->trans("Administrator").'</b>: '.yn($user->admin);
$title.='<br><b>'.$langs->trans("Type").'</b>: '.($user->societe_id?$langs->trans("External"):$langs->trans("Internal"));
$title.='<br>';
$title.='<br><u>'.$langs->trans("Connection").'</u>';
$title.='<br><b>'.$langs->trans("ConnectedSince").'</b>: '.dolibarr_print_date($user->datelastlogin,"dayhour");
$title.='<br><b>'.$langs->trans("PreviousConnexion").'</b>: '.dolibarr_print_date($user->datepreviouslogin,"dayhour");
if ($dolibarr_main_authentication) $title.='<br><b>'.$langs->trans("AuthenticationMode").'</b>: '.$dolibarr_main_authentication;
$text=''; $text.='<a href="'.DOL_URL_ROOT.'/user/logout.php"';
$text.='<a href="'.DOL_URL_ROOT.'/user/logout.php"'; $text.=$menutop->atarget?(' target="'.$menutop->atarget.'"'):'';
$text.=$menutop->atarget?(' target="'.$menutop->atarget.'"'):''; $text.='>';
$text.='>'; $text.='<img class="login" border="0" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/logout.png"';
$text.='<img class="login" border="0" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/logout.png"'; $text.=' alt="" title=""';
$text.=' alt="" title=""'; $text.='>';
$text.='>'; $text.='</a>';
$text.='</a>'; }
else
{
$text.='<img class="login" border="0" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/logout.png"';
$text.=' alt="" title=""';
$text.='>';
}
$htmltext.='<u>'.$langs->trans("User").'</u>';
$htmltext.='<br><b>'.$langs->trans("Name").'</b>: '.$user->fullname;
$htmltext.='<br><b>'.$langs->trans("Login").'</b>: '.$user->login;
$htmltext.='<br><b>'.$langs->trans("Administrator").'</b>: '.yn($user->admin);
$htmltext.='<br><b>'.$langs->trans("Type").'</b>: '.($user->societe_id?$langs->trans("External"):$langs->trans("Internal"));
$htmltext.='<br>';
$htmltext.='<br><u>'.$langs->trans("Connection").'</u>';
$htmltext.='<br><b>'.$langs->trans("ConnectedSince").'</b>: '.dolibarr_print_date($user->datelastlogin,"dayhour");
$htmltext.='<br><b>'.$langs->trans("PreviousConnexion").'</b>: '.dolibarr_print_date($user->datepreviouslogin,"dayhour");
$htmltext.='<br><b>'.$langs->trans("AuthenticationMode").'</b>: '.$_SESSION["dol_authmode"];
$html=new Form($db); $html=new Form($db);
print $html->textwithtooltip('',$title,2,1,$text); print $html->textwithtooltip('',$htmltext,2,1,$text);
// print '<img class="login" border="0" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/logout.png"'; // print '<img class="login" border="0" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/logout.png"';
// print ' alt="'.$title.'" title="'.$title.'"'; // print ' alt="'.$title.'" title="'.$title.'"';
// print '>'; // print '>';
}
print "\n</div>\n<!-- End top horizontal menu -->\n"; print "\n</div>\n<!-- End top horizontal menu -->\n";
} }

View File

@ -16,17 +16,19 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
*/ */
/** /**
\file htdocs/user/logout.php \file htdocs/user/logout.php
\brief Fichier de deconnexion \brief Fichier de deconnexion
\version $Id$
*/ */
if (!empty ($_SERVER["REMOTE_USER"])) if ($_SESSION["dol_authmode"] == 'forceuser'
die("La d&eacute;connection ne fonctionne actuellement que pour l'authentification par pear"); && $_SESSION["dol_authmode"] == 'http')
{
die("Deconexion does not work when conexion was made in mode ".$_SESSION["dol_authmode"]);
}
include_once("../conf/conf.php"); include_once("../conf/conf.php");
require_once("../main.inc.php"); require_once("../main.inc.php");