Website Summary Files Commits Branches @commit @diff @stats
path: root / controllers / 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 /controllers/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, 29 insertions, 0 deletions
-rw-r--r--controllers/user.php29
diff --git a/controllers/user.php b/controllers/user.php
index 6c0c105..d79b294 100644
--- a/controllers/user.php
+++ b/controllers/user.php
@@ -21,3 +21,32 @@ function on_post() {
$user_status = $e;
}
}
+
+function on_delete() {
+ global $TOKEN;
+ global $METHOD;
+ global $user_status;
+ $user_status = "";
+
+ try {
+ Database\Cookie::fromDB($TOKEN);
+ }
+ catch (Exception $e) {
+ $user_status = 'Invalid token!';
+ return;
+ }
+
+ $to_delete = null;
+ try {
+ $to_delete = Database\User::fromDBuid($METHOD['uid']);
+ }
+ catch(Exception $e) {
+ $list_status = "The user you're trying to delete doesn't exist!";
+ return;
+ }
+
+ $to_delete->delete();
+
+ header('Location: /');
+ exit();
+}