diff --git a/html/ajax_misc.php b/html/ajax_misc.php
index 3227b94aa..1ee537040 100644
--- a/html/ajax_misc.php
+++ b/html/ajax_misc.php
@@ -113,7 +113,22 @@ if ($op == "progressBar") {
return;
}
+//-------------------------------------------------------------------------------------------
+// check password
+//-------------------------------------------------------------------------------------------
+if ($op=='password_chk') {
+ $cnt = $http->request("pass");
+ $result=check_password_strength($cnt)['msg'];
+ if (count($result) == 0) {
+ echo json_response(["password" => "ok", "msg" => 0]);
+ } else {
+ $str="";
+ foreach ($result as $item) {$str.=sprintf("
+require_once NOALYSS_INCLUDE.'/lib/ac_common.php';
if (!defined('RECOVER'))
die('Appel direct ne sont pas permis');
define('SIZE_REQUEST', 70);
-/**
- * @brief generate a random string of char
- * @param $car int length of the string
- */
-function generate_random($car)
-{
- $string="";
- $chaine="abcdefghijklmnpqrstuvwxyABCDEFGHIJKLMNPQRSTUVWXY0123456789";
- srand((double) microtime()*1020030);
- for ($i=0; $i<$car; $i++)
- {
- $string .= $chaine[rand()%strlen($chaine)];
- }
- return $string;
-}
+
$http=new HttpInput();
/**
* @file
@@ -89,8 +76,8 @@ elseif ($action=="send_email") :
if ($valid==true):
- $request_id=generate_random(SIZE_REQUEST);
- $user_password=generate_random(10);
+ $request_id=generate_random_string(SIZE_REQUEST,special: 0);
+ $user_password=generate_random_password(10);
// exist a valid request for this user ?
$exist_request= $cn->get_array("select request , password from recover_pass
where use_id=$1 and created_on > now() - interval '12 hours'",[$user_id]);
diff --git a/include/user.inc.php b/include/user.inc.php
index c714f83e5..dddccd752 100644
--- a/include/user.inc.php
+++ b/include/user.inc.php
@@ -35,6 +35,7 @@ echo '';
if ( isset ($_POST["ADD"]) )
{
$cn=new Database();
+ $a_result =check_password_strength($_POST['PASS']);
$pass5=md5($_POST['PASS']);
$new_user=new Noalyss_user($cn,0);
$new_user->first_name=$http->post('FNAME');
@@ -45,11 +46,18 @@ if ( isset ($_POST["ADD"]) )
$login=str_replace(" ","",$login);
$login=strtolower($login);
$new_user->login=$login;
- $new_user->setPassword($pass5);
+
$new_user->email=$http->post('EMAIL',"string",'');
if ( trim($login)=="")
{
alert(_("Le login ne peut pas être vide"));
+ }elseif (count($a_result['msg']) > 0){
+ // password too weak
+ $msg=''._("Mot de passe inchangé").'';
+ foreach ($a_result['msg'] as $result ) {
+ $msg.="$result
";
+ }
+ alert($msg);
}
else
{
@@ -101,8 +109,18 @@ if ($sbaction == "save")
}
if ( trim($_POST['password'])<>'')
{
- $UserChange->setPassword(md5($_POST['password']));
- $UserChange->save();
+ $a_result =check_password_strength($_POST['password']);
+ if (count($a_result['msg']) > 0){
+ // password too weak
+ $msg=''._("Mot de passe inchangé").'';
+ foreach ($a_result['msg'] as $result ) {
+ $msg.="$result
";
+ }
+ alert($msg);
+ } else {
+ $UserChange->setPassword(md5($_POST['password']));
+ $UserChange->save();
+ }
}
else
{
@@ -168,9 +186,19 @@ if ( isset($_REQUEST['det']) && $sbaction=="")
| | |
| | |
| | |
- | | |
+
+ |
+ =\Icon_Action::tips("Mot de passe : longueur minimale = 8 dont au moins 1 majuscule, 1 minuscule,1 chiffre et 1 car.spécial")?>
+
+ |
+
+
+ |
| | |
+
id == false)
$UserChange->load();
$it_pass=new IText('password');
+$it_pass->javascript='onkeyup="check_password_strength(\'password\',\'password_info\',1)"';
$it_pass->value="";
?>