finish user-editing

This commit is contained in:
Bizarrus committed 2023-11-04 00:33:43 +01:00
1 parent 2499e97719
commit ecf0102fbc
7 files changed
+292 -27

No files matched your search

+16 -9
View File
@@ -5,21 +5,24 @@
use \fruithost\Database;
class User {
private $id = null;
private $username = null;
private $email = null;
private $data = [];
private $id = null;
private $username = null;
private $email = null;
private $crypted_mail = null;
private $data = [];
public function __construct() {}
public function fetch(int $id) {
$result = Database::single('SELECT *, "**********" as `password` FROM `' . DATABASE_PREFIX . 'users` WHERE `id`=:id LIMIT 1', [
'id' => $id
$result = Database::single('SELECT *, "**********" as `password`, UPPER(SHA2(CONCAT(`id`, :salt, `email`), 512)) AS `crypted_mail` FROM `' . DATABASE_PREFIX . 'users` WHERE `id`=:id LIMIT 1', [
'id' => $id,
'salt' => RESET_PASSWORD_SALT
]);
$this->id = $result->id;
$this->username = $result->username;
$this->email = $result->email;
$this->id = $result->id;
$this->username = $result->username;
$this->email = $result->email;
$this->crypted_mail = $result->crypted_mail;
$this->data = Database::single('SELECT * FROM `' . DATABASE_PREFIX . 'users_data` WHERE `user_id`=:user_id LIMIT 1', [
'user_id' => $this->id
@@ -88,6 +91,10 @@
return sprintf('%s %s', $this->data->name_first, $this->data->name_last);
}
public function getCryptedMail() : string | null {
return $this->crypted_mail;
}
public function getMail() : string | null {
return $this->email;
}