From f8ffe63ab3b9d16ff03b84d98f20db1b7e525e25 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sun, 2 Feb 2025 14:09:34 +0200 Subject: feat(views/user): Implement account updating (settings) --- models/user.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'models/user.php') diff --git a/models/user.php b/models/user.php index 1f58e7c..71cf07d 100644 --- a/models/user.php +++ b/models/user.php @@ -60,6 +60,20 @@ class User extends Table { private static $AnonUID = 1; + function update(string $Username, string $Password = null) { + // Applicable to Anon user + if ($this->Password === '') { + throw new Exception('Not modifying system account!'); + } + + $Password = ($Password === null) ? $this->Password : password_hash($Password, PASSWORD_BCRYPT); + Table::_update( + 'Users', + "Username = \"$Username\", Password = \"$Password\"", + "UID = \"$this->UID\"" + ); + } + function delete() { // Applicable to Anon user if ($this->Password === '') { -- cgit v1.2.3