This commit is contained in:
clementine.desrucques 2021-10-21 15:13:46 +02:00
parent 3a1a57f348
commit da2b0c201a
3 changed files with 30 additions and 17 deletions

View File

@ -173,20 +173,31 @@ public class PompierMySql {
String mdp = request.getParameter("ztMDP"); String mdp = request.getParameter("ztMDP");
String mdpChiffre = MD5.encode(request.getParameter("ztMDP")); String mdpChiffre = MD5.encode(request.getParameter("ztMDP"));
String sql = "SELECT * FROM pompier WHERE login='" + login + "' AND mdp='" + mdpChiffre + "';"; String sql = "SELECT * FROM pompier WHERE login='" + login + "' AND mdp='" + mdpChiffre + "';";
System.out.println("sql:"+sql); System.out.println("sql:" + sql);
try { try {
Statement stmt = theConnection.createStatement(); Statement stmt = theConnection.createStatement();
ResultSet resultQ = null; ResultSet resultQ = null;
resultQ = stmt.executeQuery(sql); resultQ = stmt.executeQuery(sql);
resultat = (resultQ.next()); resultat = (resultQ.next());
if(resultat){ if (resultat) {
Pompier lePompier = new Pompier( Pompier lePompier = new Pompier(
resultQ.getInt("id"), resultQ.getInt("id"),
resultQ.getInt("idCAserne"), resultQ.getInt("idCAserne"),
resultQ.getString("nom"),
resultQ.getString("prenom"),
resultQ.getInt("statut"),
resultQ.getString("mail"),
resultQ.getString("login"),
resultQ.getString("mdp"),
resultQ.getInt("adrNo"),
resultQ.getString("adrRue"),
resultQ.getString("adrCP"),
resultQ.getString("adrVille"),
resultQ.getInt("grade"),
resultQ.getString("commentaire")
); );
HttpSession maSession = request.getSession(); HttpSession maSession = request.getSession();
maSession.setAttribute("lePompier", lePompier); maSession.setAttribute("lePompier", lePompier);
} }
} catch (SQLException ex) { } catch (SQLException ex) {

View File

@ -47,19 +47,20 @@ public class NouveauPompForm {
// Creation d'un objet de type Client avec les données transmises // Creation d'un objet de type Client avec les données transmises
Pompier unPompier = new Pompier(request.getParameter("id"), Pompier unPompier = new Pompier(
request.getParameter("id"),
request.getParameter("idCaserne"), request.getParameter("idCaserne"),
request.getParameter("ztNom"), request.getParameter("nom"),
request.getParameter("ztPrenom"), request.getParameter("prenom"),
request.getParameter("nStatut"), request.getParameter("statut"),
request.getParameter("eMail"), request.getParameter("mail"),
request.getParameter("ztLogin"), request.getParameter("login"),
request.getParameter("ztMDP"), request.getParameter("mdp"),
noRue, noRue,
request.getParameter("ztAdrRue"), request.getParameter("adrRue"),
request.getParameter("ztAdrCP"), request.getParameter("adrCP"),
request.getParameter("ztAdrVille"), request.getParameter("adrVille"),
request.getParameter("nGrade"), request.getParameter("grade"),
request.getParameter("commentaire") request.getParameter("commentaire")
); );
PompierMySql cm = new PompierMySql(); PompierMySql cm = new PompierMySql();

View File

@ -79,11 +79,12 @@ public class authentifServlet extends HttpServlet {
AuthentifForm leControle = new AuthentifForm(); AuthentifForm leControle = new AuthentifForm();
// Appel de la méthode controlerRole // Appel de la méthode controlerRole
boolean isAuthentified = leControle.controlerRole(request); boolean isAuthentified = leControle.controlerRole(request);
// Création de 2 attributs de requête (isChef et leControle) // Création de 2 attributs de requête (isAuthentified et leControle)
request.setAttribute("isAuthentified", isAuthentified); request.setAttribute("isAuthentified", isAuthentified);
request.setAttribute("controlForm", leControle); request.setAttribute("controlForm", leControle);
HttpSession maSession = request.getSession(); HttpSession maSession = request.getSession();
maSession.setAttribute("isAuthentified", true); maSession.setAttribute("isAuthentified", true);
// Affichage de la JSP // Affichage de la JSP
if(isAuthentified==true){ if(isAuthentified==true){
getServletContext().getRequestDispatcher("/WEB-INF/PompierJSP.jsp") getServletContext().getRequestDispatcher("/WEB-INF/PompierJSP.jsp")