Exemple #1
0
 function resetpassword()
 {
     $userId = Users::getUserIdByCode($_POST["txtCode"]);
     if ($userId != -1) {
         $date = Users::getCodeDate($_POST["txtCode"]);
         $date = strtotime($date) + 600;
         if (strtotime(date("Y-m-d H:i:s")) <= $date) {
             if ($_POST["txtPassword"] == $_POST["txtPasswordConfirm"]) {
                 $salt = Registration::generateSalt();
                 $crypt = crypt($_POST["txtPassword"], $salt);
                 Users::updatePassword($userId, $crypt, $salt);
                 Users::deleteCode($userId);
                 header(CONNECTION_HEADER);
             }
         } else {
             Users::deleteCode($userId);
             $data = array("Forgot" => true);
             $this->renderTemplate(file_get_contents(RESET_PAGE), $data);
         }
     } else {
         Users::deleteCode($userId);
         $data = array("Forgot" => true);
         $this->renderTemplate(file_get_contents(RESET_PAGE), $data);
     }
 }
 function updatePassword()
 {
     if (isset($_POST["UserId"])) {
         $salt = Registration::generateSalt();
         $crypt = crypt($_POST["Password"], $salt);
         Users::updatePassword($_POST["UserId"], $crypt, $salt);
     }
 }
Exemple #3
0
 function addFamilyMember()
 {
     if (isset($_POST["UserName"]) && isset($_POST["UserPass"]) && isset($_POST["UserInfoTel"]) && isset($_POST["UserInfoFirstName"]) && isset($_POST["UserInfoLastName"])) {
         if (Users::isUserExistByMail($_POST["UserName"])) {
             echo json_encode(array("errors" => array("L'adresse de courriel que vous avez fournie est déjà utilisé")));
         } else {
             $salt = Registration::generateSalt();
             $crypt = crypt($_POST["UserPass"], $salt);
             $ownerId = Users::getFamilyOwnerByUserId($_SESSION["id"]);
             Users::addUser($_POST["UserName"], $_POST["UserInfoTel"], $_POST["UserInfoFirstName"], $_POST["UserInfoLastName"], $ownerId[0][0], $crypt, $salt);
             $userId = Users::getUserIdByName($_POST["UserName"]);
             $user = Users::getUser($userId);
             $phoneNumber = $user["UserInfoTel"];
             $phoneNumber = Registration::normalizePhoneNumber($phoneNumber);
             $user["UserInfoTel"] = $phoneNumber[0] . " (" . mb_substr($phoneNumber, 1, 3) . ") " . mb_substr($phoneNumber, 4, 3) . "-" . mb_substr($phoneNumber, 7, 4);
             echo json_encode($user);
         }
     }
 }
 /**
  * Éditer un administrateur de patrimoine
  *
  * TODO: Message d'erreur si l'opération échoue (transmis par un callback au client qui a envoyé la requête)
  */
 function editFamilyAdmin()
 {
     if (isset($_POST["UserId"])) {
         if (isset($_POST["UserName"])) {
             Users::updateUserName($_POST["UserId"], $_POST["UserName"]);
         }
         if (isset($_POST["UserInfoFirstName"])) {
             Users::updateFirstName($_POST["UserId"], $_POST["UserInfoFirstName"]);
         }
         if (isset($_POST["UserInfoLastName"])) {
             Users::updateLastName($_POST["UserId"], $_POST["UserInfoLastName"]);
         }
         if (isset($_POST["UserInfoTel"])) {
             $phone = Registration::normalizePhoneNumber($_POST["UserInfoTel"]);
             Users::updateTel($_POST["UserId"], $phone);
         }
         if (isset($_POST["UserPass"])) {
             if (!empty($_POST["UserPass"])) {
                 $salt = Registration::generateSalt();
                 $crypt = crypt($_POST["UserPass"], $salt);
                 Users::updatePassword($_POST["UserId"], $crypt, $salt);
             }
         }
     }
 }