From 12c46c990e8c62695ebe0e8e2316d7476d65a1b3 Mon Sep 17 00:00:00 2001 From: inghamn Date: Fri, 27 Apr 2018 15:16:11 -0400 Subject: [PATCH] Update the SESSION user when editing account info The SESSION has a copy of the current user's information. When we make changes to what's in the database, we should update the SESSION copy as well. That way, the person doesn't have to log out and back in to see changes. Updates #157 --- src/Controllers/AccountController.php | 1 + src/Controllers/PeopleController.php | 3 +++ src/Controllers/UsersController.php | 3 +++ 3 files changed, 7 insertions(+) diff --git a/src/Controllers/AccountController.php b/src/Controllers/AccountController.php index 0cb8a41..dcef07e 100644 --- a/src/Controllers/AccountController.php +++ b/src/Controllers/AccountController.php @@ -32,6 +32,7 @@ public function update() try { $person->handleUpdate($_POST); $person->save(); + $_SESSION['USER'] = $person; header('Location: '.BASE_URI.'/account'); exit(); diff --git a/src/Controllers/PeopleController.php b/src/Controllers/PeopleController.php index d007b40..e9e94f3 100644 --- a/src/Controllers/PeopleController.php +++ b/src/Controllers/PeopleController.php @@ -61,6 +61,9 @@ public function update() try { $person->handleUpdate($_POST); $person->save(); + if ($_SESSION['USER']->getId() == $person->getId()) { + $_SESSION['USER'] = $person; + } header("Location: $return_url"); exit(); diff --git a/src/Controllers/UsersController.php b/src/Controllers/UsersController.php index a4a417f..b203deb 100644 --- a/src/Controllers/UsersController.php +++ b/src/Controllers/UsersController.php @@ -44,6 +44,9 @@ public function update() try { $person->handleUpdateUserAccount($_POST); $person->save(); + if ($_SESSION['USER']->getId() == $person->getId()) { + $_SESSION['USER'] = $person; + } header('Location: '.BASE_URL.'/users'); exit(); }