Website Summary Files Commits Branches @commit @diff @stats
path: root / models / user.php
diff options
context:
space:
mode:
Commitf8ffe63ab3b9d16ff03b84d98f20db1b7e525e25 (patch)
Author
 Syndamia <kamen@syndamia.com>
2025-02-02 14:09:34 +0200
Committer
 Syndamia <kamen@syndamia.com>
2025-02-02 14:09:34 +0200
Files887dac6380c1897e9087200f25ffec6f451fc3ec /models/user.php
nowayforward_human-f8ffe63ab3b9d16ff03b84d98f20db1b7e525e25.tar
nowayforward_human-f8ffe63ab3b9d16ff03b84d98f20db1b7e525e25.tar.gz
nowayforward_human-f8ffe63ab3b9d16ff03b84d98f20db1b7e525e25.zip
Parent0e4f90e6a82f0fc275d65bf0e4f4c2842052dde9 (diff)
feat(views/user): Implement account updating (settings)
1 files changed, 14 insertions, 0 deletions
-rw-r--r--models/user.php14
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 === '') {