ajout modif besnik du 4 mars
Some checks are pending
Deploy production (servyass) / deploy (push) Waiting to run
Some checks are pending
Deploy production (servyass) / deploy (push) Waiting to run
This commit is contained in:
parent
0f70b82e4b
commit
2cb4def949
5 changed files with 220 additions and 157 deletions
|
|
@ -90,45 +90,14 @@ class UserCtrl extends MotherCtrl {
|
|||
$objUser = new User();
|
||||
$strPwdConfirm = $_POST['pwd_confirm'] ?? "";
|
||||
|
||||
$objUser->hydrate($_POST);
|
||||
|
||||
$arrError = [];
|
||||
|
||||
if (!empty($_POST)) {
|
||||
$objUser->setName($_POST['user_name'] ?? "");
|
||||
$objUser->setFirstname($_POST['user_firstname'] ?? "");
|
||||
$objUser->setMail($_POST['user_mail'] ?? "");
|
||||
$objUser->setPseudo($_POST['user_pseudo'] ?? "");
|
||||
$objUser->setPwd($_POST['user_password'] ?? "");
|
||||
$objUser->setPhone($_POST['user_phone'] ?? "");
|
||||
$objUser->setWork($_POST['user_work'] ?? "");
|
||||
$objUser->setLocation($_POST['user_location'] ?? "");
|
||||
$objUser->setDescription($_POST['user_description'] ?? "");
|
||||
|
||||
if (trim($objUser->getName()) === "") {
|
||||
$arrError['user_name'] = "Le nom est obligatoire";
|
||||
}
|
||||
|
||||
if (trim($objUser->getFirstname()) === "") {
|
||||
$arrError['user_firstname'] = "Le prénom est obligatoire";
|
||||
}
|
||||
|
||||
if (trim($objUser->getMail()) === "") {
|
||||
$arrError['user_mail'] = "L'adresse e-mail est obligatoire";
|
||||
} elseif (!filter_var($objUser->getMail(), FILTER_VALIDATE_EMAIL)) {
|
||||
$arrError['user_mail'] = "Le format de l'adresse e-mail est invalide";
|
||||
}
|
||||
|
||||
if (trim($objUser->getPseudo()) === "") {
|
||||
$arrError['user_pseudo'] = "Le pseudo est obligatoire";
|
||||
}
|
||||
|
||||
$strRegex = "/^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#?!@$%^&*-]).{15,}$/";
|
||||
if ($objUser->getPwd() == ""){
|
||||
$arrError['user_password'] = "Le mot de passe est obligatoire";
|
||||
}else if (!preg_match($strRegex, $objUser->getPwd())){
|
||||
$arrError['user_password'] = "Le mot de passe ne respecte pas les critères";
|
||||
}else if($objUser->getPwd() != $strPwdConfirm){
|
||||
$arrError['pwd_confirm'] = "La confirmation du mot de passe ne correspond pas";
|
||||
}
|
||||
|
||||
$arrError = array_merge($this->_verifInfos($objUser),
|
||||
$this->_verifPwd($objUser, $strPwdConfirm));
|
||||
|
||||
if (count($arrError) === 0) {
|
||||
$objUserModel = new UserModel();
|
||||
|
|
@ -156,6 +125,55 @@ class UserCtrl extends MotherCtrl {
|
|||
$this->_arrData['arrError'] = $arrError;
|
||||
$this->_display("signup");
|
||||
}
|
||||
|
||||
|
||||
protected function _verifInfos(User $objUser): array {
|
||||
|
||||
$arrError = [];
|
||||
|
||||
if (trim($objUser->getName()) === "") {
|
||||
$arrError['user_name'] = "Le nom est obligatoire";
|
||||
}
|
||||
|
||||
if (trim($objUser->getFirstname()) === "") {
|
||||
$arrError['user_firstname'] = "Le prénom est obligatoire";
|
||||
}
|
||||
|
||||
if (trim($objUser->getMail()) === "") {
|
||||
$arrError['user_mail'] = "L'adresse e-mail est obligatoire";
|
||||
} elseif (!filter_var($objUser->getMail(), FILTER_VALIDATE_EMAIL)) {
|
||||
$arrError['user_mail'] = "Le format de l'adresse e-mail est invalide";
|
||||
}
|
||||
|
||||
if (trim($objUser->getPseudo()) === "") {
|
||||
$arrError['user_pseudo'] = "Le pseudo est obligatoire";
|
||||
}
|
||||
|
||||
return $arrError;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Vérification du mot de passe
|
||||
*/
|
||||
protected function _verifPwd(User $objUser, string $strPwdConfirm): array {
|
||||
|
||||
$arrError = [];
|
||||
|
||||
$strRegex = "/^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#?!@$%^&*-]).{15,}$/";
|
||||
|
||||
if ($objUser->getPwd() == ""){
|
||||
$arrError['user_password'] = "Le mot de passe est obligatoire";
|
||||
}
|
||||
else if (!preg_match($strRegex, $objUser->getPwd())){
|
||||
$arrError['user_password'] = "Le mot de passe ne respecte pas les critères";
|
||||
}
|
||||
else if ($objUser->getPwd() != $strPwdConfirm){
|
||||
$arrError['pwd_confirm'] = "La confirmation du mot de passe ne correspond pas";
|
||||
}
|
||||
|
||||
return $arrError;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue