aboutsummaryrefslogtreecommitdiff
path: root/models/user.php
diff options
context:
space:
mode:
authorSyndamia <kamen@syndamia.com>2025-02-02 14:09:34 +0200
committerSyndamia <kamen@syndamia.com>2025-02-02 14:09:34 +0200
commitf8ffe63ab3b9d16ff03b84d98f20db1b7e525e25 (patch)
tree887dac6380c1897e9087200f25ffec6f451fc3ec /models/user.php
parent0e4f90e6a82f0fc275d65bf0e4f4c2842052dde9 (diff)
downloadnowayforward_human-f8ffe63ab3b9d16ff03b84d98f20db1b7e525e25.tar
nowayforward_human-f8ffe63ab3b9d16ff03b84d98f20db1b7e525e25.tar.gz
nowayforward_human-f8ffe63ab3b9d16ff03b84d98f20db1b7e525e25.zip
feat(views/user): Implement account updating (settings)
Diffstat (limited to 'models/user.php')
-rw-r--r--models/user.php14
1 files changed, 14 insertions, 0 deletions
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 === '') {