Merge branch 'main' of https://git.bib.de/PBBFA23AHR/kurs-app
This commit is contained in:
@@ -11,31 +11,30 @@ class UserModel extends Database
|
||||
/**
|
||||
* @throws RandomException
|
||||
*/
|
||||
public function createUser($values)
|
||||
{
|
||||
public function createUser($values){
|
||||
|
||||
$salt = bin2hex(random_bytes(16));
|
||||
|
||||
$hash = hash('sha256', $values["password"] . $salt);
|
||||
|
||||
$guid = $this->createUUID();
|
||||
$guid = rand(0, 500);
|
||||
|
||||
$pdo = $this->linkDB();
|
||||
|
||||
$sql = "INSERT INTO users (`id`,`vorname`,`name`,`email`,`passwort`,`salt`,`role`)
|
||||
VALUES (:guid, :name, :lastname, :email, :password, :salt, :role)";
|
||||
$sql = "INSERT INTO user (`id`, `name`,`vorname`,`email`,`passwort`,`salt`,`role`)
|
||||
VALUES (:guid, :name, :firstname, :email, :password, :salt, :role)";
|
||||
|
||||
try {
|
||||
$sth = $pdo->prepare($sql);
|
||||
$sth->execute(array
|
||||
(":guid" => $guid,
|
||||
(":name") => $values["name"],
|
||||
":lastname" => $values["lastname"],
|
||||
$sth->execute([
|
||||
":guid" => $guid,
|
||||
":name" => $values["name"],
|
||||
":firstname" => $values["lastname"],
|
||||
":email" => $values["email"],
|
||||
":password" => $hash,
|
||||
":salt" => $salt,
|
||||
":role" => $values["role"]
|
||||
));
|
||||
]);
|
||||
} catch (PDOException $e) {
|
||||
new \Blog\Library\ErrorMsg("Fehler beim Schreiben der Daten.", $e);
|
||||
die;
|
||||
@@ -44,4 +43,12 @@ class UserModel extends Database
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getUserByEmail($email){
|
||||
$pdo = $this->linkDB();
|
||||
$sql = "SELECT * FROM user WHERE email = :email";
|
||||
$sth = $pdo->prepare($sql);
|
||||
$sth->execute([":email" => $email]);
|
||||
return $sth->fetch();
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user