diff --git a/src/controllers/Profile.php b/src/controllers/Profile.php index f7eca13..37a9897 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['confirmation_message'] = false; } private function handleLogOut(): void @@ -39,9 +40,31 @@ private function handleLogOut(): void private function handleAccountDeletion(): void { - // delete user account if delete button clicked - $this->signed_client->deleteUser(); - $this->handleLogOut(); + // Display confirmation message + $confirmation_message = "Are you sure you want to delete your account? This action is irreversible."; + $this->view_data['confirmation_message'] = $confirmation_message; + + // 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 + ); } /** @@ -182,6 +205,7 @@ public function index(): void // delete user account if delete button clicked if (isset($_GET['account_delete_submit'])) { + $this->view_data['confirmation_message'] = true; $this->handleAccountDeletion(); return; } diff --git a/src/views/Profile.php b/src/views/Profile.php index 10d5ad1..0f6142e 100644 --- a/src/views/Profile.php +++ b/src/views/Profile.php @@ -162,6 +162,7 @@
+ @@ -203,3 +204,13 @@ function openTab(evt, tabName) { + \ No newline at end of file