Website Summary Files Commits Branches @commit @diff @stats
path: root / models / user.php
diff options
context:
space:
mode:
Commit0e4f90e6a82f0fc275d65bf0e4f4c2842052dde9 (patch)
Author
 Syndamia <kamen@syndamia.com>
2025-02-02 13:43:26 +0200
Committer
 Syndamia <kamen@syndamia.com>
2025-02-02 13:43:26 +0200
Files892ccf952d364f03734ed95950845037fef26179 /models/user.php
nowayforward_human-0e4f90e6a82f0fc275d65bf0e4f4c2842052dde9.tar
nowayforward_human-0e4f90e6a82f0fc275d65bf0e4f4c2842052dde9.tar.gz
nowayforward_human-0e4f90e6a82f0fc275d65bf0e4f4c2842052dde9.zip
Parent168abc2c8512343f2a65461c6791ae852ae64665 (diff)
feat(views/user): Implement account deletion
1 files changed, 26 insertions, 0 deletions
-rw-r--r--models/user.php26
diff --git a/models/user.php b/models/user.php
index 9b76f37..1f58e7c 100644
--- a/models/user.php
+++ b/models/user.php
@@ -57,4 +57,30 @@ class User extends Table {
include $VIEWS_DIR . '/img/user-star.svg';
}
}
+
+ private static $AnonUID = 1;
+
+ function delete() {
+ // Applicable to Anon user
+ if ($this->Password === '') {
+ throw new Exception('Not deleting system account!');
+ }
+
+ Table::_update(
+ 'Webpages',
+ 'RequesterUID = "' . self::$AnonUID . '"',
+ "RequesterUID = \"$this->UID\""
+ );
+
+ Table::_update(
+ 'ArchiveLists',
+ 'AuthorUID = "' . self::$AnonUID . '"',
+ "AuthorUID = \"$this->UID\""
+ );
+
+ Table::_delete(
+ 'Users',
+ "UID = \"$this->UID\""
+ );
+ }
}