/*
 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
 */
package form;

import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpSession;
import mysql.utilisateurMysql;

/**
 *
 * @author francois
 */
public class AuthentifForm {
    HttpServletRequest request;
    
    public AuthentifForm(HttpServletRequest request) {
        this.request = request;
    }

    public boolean ctrlAuthentif(String username, String mail, String mdp) {
        utilisateurMysql utilisateurSQL = new utilisateurMysql();
        var utilisateurLogged = utilisateurSQL.readAuthentif(username, mdp);
        if (utilisateurLogged != null) {
            HttpSession maSession = request.getSession(true);
            maSession.setAttribute("currentUtilisateur", utilisateurLogged);
            return true;
        } else {
            return false;
        }
    }
}
