Skip to content
Snippets Groups Projects
Commit 06327fec authored by Moreau Elise's avatar Moreau Elise
Browse files

redirect Session variable between routes

parent 18e63cee
No related branches found
No related tags found
No related merge requests found
...@@ -14,15 +14,15 @@ class DeleteUserAction extends UserAction ...@@ -14,15 +14,15 @@ class DeleteUserAction extends UserAction
*/ */
protected function action(): Response protected function action(): Response
{ {
$userId = (int) $this->resolveArg('id'); $userId = $_SESSION['userId'];
$user = $this->userRepository->find($userId); $user = $this->userRepository->find($userId);
$this->em->remove($user); $this->em->remove($user);
$this->em->flush(); $this->em->flush();
$this->logger->info("User has been deleted."); $this->logger->info("User has been deleted.");
session_unset();
return $this->respondWithData($user); return $this->twig->render($this->response, "/home/home.twig", []);
} }
} }
...@@ -21,6 +21,6 @@ class ListUsersAction extends UserAction ...@@ -21,6 +21,6 @@ class ListUsersAction extends UserAction
$this->logger->info("Users list was viewed."); $this->logger->info("Users list was viewed.");
return $this->twig->render($this->response, "/user/list_users.twig", ["users" => $users, "session" => $this->request->session]); return $this->twig->render($this->response, "/user/list_users.twig", ["users" => $users, "session" => $_SESSION]);
} }
} }
...@@ -27,6 +27,6 @@ class ViewAccountAction extends UserAction ...@@ -27,6 +27,6 @@ class ViewAccountAction extends UserAction
} }
$this->logger->info("User of id `{$user->getId()}` was viewed."); $this->logger->info("User of id `{$user->getId()}` was viewed.");
return $this->twig->render($this->response, "/user/user_profile.twig", ["user" => $user, "id"=> $user->getId()]); return $this->twig->render($this->response, "/user/user_profile.twig", ["user" => $user, "id"=> $user->getId(), "session" => $_SESSION]);
} }
} }
...@@ -26,6 +26,6 @@ class ViewModifyForm extends UserAction ...@@ -26,6 +26,6 @@ class ViewModifyForm extends UserAction
throw new UserNotFoundException(); throw new UserNotFoundException();
} }
return $this->twig->render($this->response, "/user/modify_user.twig", ["user" => $user]); return $this->twig->render($this->response, "/user/modify_user.twig", ["user" => $user, "session" => $_SESSION]);
} }
} }
...@@ -21,6 +21,6 @@ class ViewUserAction extends UserAction ...@@ -21,6 +21,6 @@ class ViewUserAction extends UserAction
} }
$this->logger->info("User of id `${userId}` was viewed."); $this->logger->info("User of id `${userId}` was viewed.");
return $this->twig->render($this->response, "/user/user_profile.twig", ["user" => $user]); return $this->twig->render($this->response, "/user/user_profile.twig", ["user" => $user, "session" => $_SESSION]);
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment