diff --git a/htdocs/user/passwordforgotten.php b/htdocs/user/passwordforgotten.php
index b9e338e8ea3..95ee92473fe 100644
--- a/htdocs/user/passwordforgotten.php
+++ b/htdocs/user/passwordforgotten.php
@@ -29,6 +29,7 @@ require("../master.inc.php");
require_once(DOL_DOCUMENT_ROOT."/contact.class.php");
require_once(DOL_DOCUMENT_ROOT."/lib/ldap.class.php");
require_once(DOL_DOCUMENT_ROOT."/lib/usergroups.lib.php");
+require_once(DOL_DOCUMENT_ROOT.'/includes/cryptographp/cryptographp.fct.php');
$user->getrights('user');
@@ -76,40 +77,50 @@ if ($_GET["action"] == 'validatenewpassword' && $_GET["username"] && $_GET["pass
// Action modif mot de passe
if ($_POST["action"] == 'buildnewpassword' && $_POST["username"])
{
- $edituser = new User($db);
- $result=$edituser->fetch($_POST["username"]);
- if ($result < 0)
+ // Verifie code
+ if (! chk_crypt($_POST['code']))
{
- $message = '
'.$langs->trans("ErrorLoginDoesNotExists",$_POST["username"]).'
';
+ $message = ''.$langs->trans("ErrorBadValueForCode").'
';
}
else
{
- if (! $edituser->email)
+ $edituser = new User($db);
+ $result=$edituser->fetch($_POST["username"]);
+ if ($result < 0)
{
- $message = ''.$langs->trans("ErrorLoginHasNoEmail").'
';
+ $message = ''.$langs->trans("ErrorLoginDoesNotExists",$_POST["username"]).'
';
+ $_POST["username"]='';
}
else
{
- $newpassword=$edituser->password($user,'',$conf->password_encrypted,1);
- if ($newpassword < 0)
- {
- // Echec
- $message = ''.$langs->trans("ErrorFailedToChangePassword").'
';
- }
- else
- {
- // Succes
- if ($edituser->send_password($user,$newpassword,1) > 0)
- {
- $message = ''.$langs->trans("PasswordChangedAndSentTo",$edituser->email).'
';
- //$message.=$newpassword;
- }
- else
- {
- //$message = ''.$langs->trans("PasswordChangedTo",$newpassword).'
';
+ if (! $edituser->email)
+ {
+ $message = ''.$langs->trans("ErrorLoginHasNoEmail").'
';
+ }
+ else
+ {
+ $newpassword=$edituser->password($user,'',$conf->password_encrypted,1);
+ if ($newpassword < 0)
+ {
+ // Echec
+ $message = ''.$langs->trans("ErrorFailedToChangePassword").'
';
+ }
+ else
+ {
+ // Succes
+ if ($edituser->send_password($user,$newpassword,1) > 0)
+ {
+ $message = ''.$langs->trans("PasswordChangeRequestSent",$edituser->login,$edituser->email).'
';
+ //$message.=$newpassword;
+ $_POST["username"]='';
+ }
+ else
+ {
+ //$message = ''.$langs->trans("PasswordChangedTo",$newpassword).'
';
$message.= ''.$edituser->error.'
';
- }
- }
+ }
+ }
+ }
}
}
}
@@ -124,6 +135,8 @@ $conf->css = "theme/".$conf->theme."/".$conf->theme.".css";
// Si feuille de style en php existe
if (file_exists(DOL_DOCUMENT_ROOT.'/'.$conf->css.".php")) $conf->css.=".php";
+header('Cache-Control: Public, must-revalidate');
+
print ''."\n";
// En tete html
@@ -191,7 +204,7 @@ print '| '.$langs->trans("Login").' | ';
+print ' | ';
$title='';
@@ -211,12 +224,20 @@ elseif (is_readable(DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/img/login_logo.pn
{
$urllogo=DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/login_logo.png';
}
-print '  | ';
-
+
print '
'."\n";
+//print "Info session: ".session_name().session_id();print_r($_SESSION);
+$cryptinstall = DOL_URL_ROOT.'/includes/cryptographp';
+print '| '.$langs->trans("SecurityCode").' | ';
+print ' | ';
+print '';
+dsp_crypt('dolibarr.cfg.php',1);
+print ' | ';
+print '
';
print "".' |
'."\n";
print ""."\n";
@@ -224,16 +245,24 @@ print ""."\n";
print ""."\n";
print ''."\n";
-if ($mode == 'dolibarr')
+print '';
+if (! $mode == 'dolibarr' || $conf->global->MAIN_SECURITY_FORCEFORGETPASSLINK)
{
- print '| '.$langs->trans("SendNewPasswordDesc").' |
'."\n";
+ print ''.$langs->trans("SendNewPasswordDesc").''."\n";
}
else
{
print ''.$langs->trans("AuthenticationDoesNotAllowSendNewPassword",$mode).' '."\n";
}
+print ' |
';
+
+if ($message)
+{
+ print '
';
+}
+
print '
'."\n";
-if ($message) { print $message.'
'; }
print ''.$langs->trans("BackToLoginPage").'';
print ''."\n";