Skip to content
Snippets Groups Projects
Commit 03010ac7 authored by Laurent Destailleur's avatar Laurent Destailleur
Browse files

Can still connect if option do not save clear password is reversed.

parent 3ad5d6b5
No related branches found
No related tags found
No related merge requests found
......@@ -61,9 +61,11 @@ if ($_GET["action"] == 'activate_encrypt')
$db->begin();
dolibarr_set_const($db, "DATABASE_PWD_ENCRYPTED", "1");
$sql = "UPDATE ".MAIN_DB_PREFIX."user as u";
$sql.= " SET u.pass = NULL AND u.pass_crypted = MD5(u.pass)";
$sql.= " SET u.pass_crypted = MD5(u.pass), u.pass = NULL";
$sql.= " WHERE u.pass IS NOT NULL AND LENGTH(u.pass) < 32"; // Not a MD5 value
$sql.= " AND MD5(u.pass) IS NOT NULL";
//print $sql;
$result = $db->query($sql);
......@@ -75,6 +77,7 @@ if ($_GET["action"] == 'activate_encrypt')
}
else
{
$db->rollback();
dolibarr_print_error($db,'');
}
}
......
......@@ -63,23 +63,33 @@ function check_user_password_dolibarr($usertotest,$passwordtotest)
// Check crypted password
$cryptType='';
if ($conf->global->DATABASE_PWD_ENCRYPTED) $cryptType='md5';
if (! empty($conf->global->DATABASE_PWD_ENCRYPTED)) $cryptType=$conf->global->DATABASE_PWD_ENCRYPTED;
// By default, we used MD5
if (! in_array($cryptType,array('md5'))) $cryptType='md5';
// Check crypted password according to crypt algorithm
if ($cryptType == 'md5')
{
if (md5($passtyped) == $passcrypted) $passok=true;
if (md5($passtyped) == $passcrypted)
{
$passok=true;
dolibarr_syslog("functions_dolibarr::check_user_password_dolibarr Authentification ok - ".$cryptType." of pass is ok");
}
}
// For compatibility with old versions
if (! $passok)
{
if ((! $passcrypted || $passtyped)
&& ($passtyped == $passclear)) $passok=true;
&& ($passtyped == $passclear))
{
$passok=true;
dolibarr_syslog("functions_dolibarr::check_user_password_dolibarr Authentification ok - found pass in database");
}
}
// Password ok ?
if ($passok)
{
dolibarr_syslog("functions_dolibarr::check_user_password_dolibarr Authentification ok");
$login=$_POST["username"];
}
else
......
......@@ -19,9 +19,9 @@
*/
/**
\file htdocs/index.php
\brief Page accueil par defaut
\version $Id$
* \file htdocs/index.php
* \brief Page accueil par defaut
* \version $Id$
*/
require("./pre.inc.php");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment