diff options
| author | Syndamia <kamen@syndamia.com> | 2025-02-02 15:52:58 +0200 |
|---|---|---|
| committer | Syndamia <kamen@syndamia.com> | 2025-02-02 15:52:58 +0200 |
| commit | e0fe3d0a5b6dd8bf4ba11eee10adfb6be3f5ab31 (patch) | |
| tree | e0562c4683f27c7700ceb16e6faa3a06dd3f50f8 /models/user.php | |
| parent | 179ebaebc36b6dc470dacad5a9020e4d6bf9921a (diff) | |
| download | nowayforward_human-e0fe3d0a5b6dd8bf4ba11eee10adfb6be3f5ab31.tar nowayforward_human-e0fe3d0a5b6dd8bf4ba11eee10adfb6be3f5ab31.tar.gz nowayforward_human-e0fe3d0a5b6dd8bf4ba11eee10adfb6be3f5ab31.zip | |
feat: Implement admin panel with the ability to change role of users
Diffstat (limited to 'models/user.php')
| -rw-r--r-- | models/user.php | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/models/user.php b/models/user.php index 71cf07d..6ff2f70 100644 --- a/models/user.php +++ b/models/user.php @@ -60,16 +60,18 @@ class User extends Table { private static $AnonUID = 1; - function update(string $Username, string $Password = null) { + function update(string $Username = null, string $Password = null, string $Role = null) { // Applicable to Anon user if ($this->Password === '') { throw new Exception('Not modifying system account!'); } + $Username = $Username ?? $this->Username; $Password = ($Password === null) ? $this->Password : password_hash($Password, PASSWORD_BCRYPT); + $Role = $Role ?? $this->Role; Table::_update( 'Users', - "Username = \"$Username\", Password = \"$Password\"", + "Username = \"$Username\", Password = \"$Password\", Role = \"$Role\"", "UID = \"$this->UID\"" ); } |
