From 0e4f90e6a82f0fc275d65bf0e4f4c2842052dde9 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sun, 2 Feb 2025 13:43:26 +0200 Subject: feat(views/user): Implement account deletion --- models/user.php | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'models') 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\"" + ); + } } -- cgit v1.2.3