Skip to content

Commit

Permalink
Update the SESSION user when editing account info
Browse files Browse the repository at this point in the history
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
  • Loading branch information
inghamn committed Apr 27, 2018
1 parent 1d3f39f commit 12c46c9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Controllers/AccountController.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public function update()
try {
$person->handleUpdate($_POST);
$person->save();
$_SESSION['USER'] = $person;

header('Location: '.BASE_URI.'/account');
exit();
Expand Down
3 changes: 3 additions & 0 deletions src/Controllers/PeopleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
3 changes: 3 additions & 0 deletions src/Controllers/UsersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down

0 comments on commit 12c46c9

Please sign in to comment.