Website Summary Files Commits Branches @commit @diff @stats
path: root / models / user.php
diff options
context:
space:
mode:
Commite0fe3d0a5b6dd8bf4ba11eee10adfb6be3f5ab31 (patch)
Author
 Syndamia <kamen@syndamia.com>
2025-02-02 15:52:58 +0200
Committer
 Syndamia <kamen@syndamia.com>
2025-02-02 15:52:58 +0200
Filese0562c4683f27c7700ceb16e6faa3a06dd3f50f8 /models/user.php
nowayforward_human-e0fe3d0a5b6dd8bf4ba11eee10adfb6be3f5ab31.tar
nowayforward_human-e0fe3d0a5b6dd8bf4ba11eee10adfb6be3f5ab31.tar.gz
nowayforward_human-e0fe3d0a5b6dd8bf4ba11eee10adfb6be3f5ab31.zip
Parent179ebaebc36b6dc470dacad5a9020e4d6bf9921a (diff)
feat: Implement admin panel with the ability to change role of users
1 files changed, 4 insertions, 2 deletions
-rw-r--r--models/user.php6
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\""
);
}