Skip to content
Snippets Groups Projects
Commit 78f56071 authored by Maxime Gosselin's avatar Maxime Gosselin
Browse files

Account gère les erreurs

parent 80522032
No related branches found
No related tags found
No related merge requests found
......@@ -15,6 +15,13 @@ import modele.dto.User;
public class Account extends HttpServlet{
@Override
public void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
String username = (String) req.getSession().getAttribute("username");
// vérification de l'authentification
if(username == null){
resp.sendRedirect("index.html");
return ;
}
String action = (String) req.getParameter("action");
HttpSession session = req.getSession();
DaoUser daoUser = new DaoUser();
......@@ -25,7 +32,6 @@ public class Account extends HttpServlet{
resp.sendRedirect("index.html");
break;
case "update":
String username = (String) session.getAttribute("username");
String firstname = req.getParameter("firstname");
String lastname = req.getParameter("lastname");
......@@ -35,6 +41,10 @@ public class Account extends HttpServlet{
daoUser.update(user);
resp.sendRedirect("navigation?page=compte");
break;
default:
req.setAttribute("error", "Ne changez pas l'url vous même!");
req.getRequestDispatcher("/WEB-INF/vue/error.jsp");
return;
}
}
}
\ No newline at end of file
<%@ page contentType="text/html; charset=UTF-8"%>
<html>
ERREUR : <%=request.getAttribute("error") %>
</html>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment