Auth angepasst

This commit is contained in:
2025-06-27 10:24:21 +02:00
parent 5477e7fdd8
commit 36d6364cd0
4 changed files with 130 additions and 123 deletions

View File

@@ -2,7 +2,8 @@
namespace Blog\Model;
use Cassandra\Date;
use DateTime;
use PDO;
use PDOException;
class AuthModel extends Database
@@ -41,8 +42,7 @@ class AuthModel extends Database
return true;
}
public function register($email, $password, $street, $houseNumber, $city, $postalCode, $country, $firstName, $lastName, $phone)
{
public function register($email, $password, $street, $houseNumber, $city, $postalCode, $country, $firstName, $lastName, $phone, $isAdmin) {
$rtn = $this->pwRequirementCheck($password);
if($rtn !== true){
return $rtn;
@@ -61,41 +61,41 @@ class AuthModel extends Database
try {
$pdo = $this->linkDB();
$stmt = $pdo->prepare("SELECT id FROM user WHERE email = :email");
$stmt = $pdo->prepare("SELECT userid FROM user WHERE email = :email");
$stmt->execute([':email' => $email]);
if($stmt-> fetch()){
return "Der Account mit der Email, existiert bereits.";
}
}
catch (PDOException $e){
} catch (PDOException $e){
new \Blog\Library\ErrorMsg("Fehler beim Abrufen der Daten", $e);
die;
}
$hashedPassword = password_hash($password, PASSWORD_DEFAULT);
$hashedPassword = password_hash($password, PASSWORD_DEFAULT);
$sql = "INSERT INTO user (email, password, straße, hausnr, ort, postleitzahl,land, vorname, nachname, tel)
VALUES (:email, :password, :straße, :hausnr, :ort, :postleitzahl, :land, :vorname, :nachname, :tel)";
$sql = "INSERT INTO user (email, password, straße, hausnr, ort, postleitzahl,land, vorname, nachname, tel, isAdmin)
VALUES (:email, :password, :straße, :hausnr, :ort, :postleitzahl, :land, :vorname, :nachname, :tel, :isAdmin)";
try{
$pdo = $this->linkDB();
$stmt = $pdo->prepare($sql);
return $stmt->execute([
':email' => $email,
':password' => $hashedPassword,
':straße' => $street,
':hausnr' => $houseNumber,
':ort' => $city,
':postleitzahl' => $postalCode,
':land' => $country,
':vorname' => $firstName,
':nachname' => $lastName,
':tel' => $phone
]);
} catch (PDOException $e) {
new \Blog\Library\ErrorMsg("Fehler beim Schreiben der Daten.", $e);
die;
}
try{
$pdo = $this->linkDB();
$stmt = $pdo->prepare($sql);
$stmt->execute([
':email' => $email,
':password' => $hashedPassword,
':straße' => $street,
':hausnr' => $houseNumber,
':ort' => $city,
':postleitzahl' => $postalCode,
':land' => $country,
':vorname' => $firstName,
':nachname' => $lastName,
':tel' => $phone,
':isAdmin' => $isAdmin
]);
} catch (PDOException $e) {
new \Blog\Library\ErrorMsg("Fehler beim Schreiben der Daten.", $e);
die;
}
}
@@ -110,8 +110,8 @@ class AuthModel extends Database
$error[] = "min one small charakter";
if(!preg_match("/[0-9]/", $password))
$error[] = "min one number";
if(!preg_match("/[ <>|°^,;·.:…\-_#'+*~!¹\"²§³\$¼%½&¬/{([)]=}?ß\\\`¸´¡⅛£¤⅜⅝⅞™±¿˛¯˘—÷×»«¢„“”µþø→↓←ŧ¶€ſ@æſðđŋħ.ĸłµ”“„¢«»›‹©‚‘’ºÆẞЪŊĦ˙&ŁΩ§€®Ŧ¥↑ıØÞ ]/", $password));
$error[] = "min one of these: <>|°^,;·.:…\-_#'+*~!¹\"²§³\$¼%½&¬/{([)]=}?ß\\\`¸´¡⅛£¤⅜⅝⅞™±¿˛¯˘—÷×»«¢„“”µþø→↓←ŧ¶€ſ@æſðđŋħ.ĸłµ”“„¢«»›‹©‚‘’ºÆẞЪŊĦ˙&ŁΩ§€®Ŧ¥↑ıØÞ";
if(!preg_match("[^a-zA-Z0-9\s]", $password));
$error[] = "min one special character";
if(empty($error))
return true;