diff options
Diffstat (limited to 'controllers/user.php')
| -rw-r--r-- | controllers/user.php | 29 |
1 files changed, 29 insertions, 0 deletions
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(); +} |
