diff --git a/src/controllers/Profile.php b/src/controllers/Profile.php index f7eca13..be9e8e0 100644 --- a/src/controllers/Profile.php +++ b/src/controllers/Profile.php @@ -22,6 +22,7 @@ public function __construct() $this->signed_client = null; $this->view_data['errors'] = []; $this->view_data['client'] = null; + $this->view_data['show_account_deletion_confirmation'] = false; } private function handleLogOut(): void @@ -39,9 +40,29 @@ private function handleLogOut(): void private function handleAccountDeletion(): void { - // delete user account if delete button clicked - $this->signed_client->deleteUser(); - $this->handleLogOut(); + $this->view_data['show_account_deletion_confirmation'] = true; + + // Check if the deletion confirmation has been submitted + if (isset($_POST['confirm_delete'])) { + // Perform account deletion + $this->signed_client->deleteUser(); + $this->handleLogOut(); + return; + } + + // Check if cancel button is clicked + if (isset($_POST['cancel_delete'])) { + Utility::redirect('profile'); + return; + } + + // Render the view with the confirmation message + $this->view( + 'Profile', + $this->view_data, + 'Profile', + enableIndexing: false + ); } /** diff --git a/src/views/Profile.php b/src/views/Profile.php index 10d5ad1..54d9425 100644 --- a/src/views/Profile.php +++ b/src/views/Profile.php @@ -6,6 +6,7 @@ * The following attributes are defined in controllers/Profile.php * * @var $client Client signed in client + * @var $show_account_deletion_confirmation bool Whether to display a confirmation dialog for account deletion * @var $orders array array of orders */ @@ -162,6 +163,7 @@
+ @@ -202,4 +204,19 @@ function openTab(evt, tabName) { - + + +