/** * Removes User from the Group * * <p>- Requires a cookie for the session user - Requires a groupId request parameter for the HTTP * GET * * @param req The HTTP Request * @param res The HTTP Response */ public void leaveAction(HttpServletRequest req, HttpServletResponse res) { if (AccountController.redirectIfNoCookie(req, res)) return; if (req.getMethod() == HttpMethod.Get) { int groupId = Integer.parseInt(req.getParameter("groupId")); HttpSession session = req.getSession(); Session userSession = (Session) session.getAttribute("userSession"); int userId = userSession.getUser().getId(); GroupManager groupMan = new GroupManager(); groupMan.removeMapping(groupId, userId); // reload groups into the user userSession.getUser().setGroups(groupMan.getAllGroups(userId)); redirectToLocal(req, res, "/home/dashboard"); return; } else { httpNotFound(req, res); } }