package br.dsc.upe.poli.mvc;

import javax.servlet.RequestDispatcher;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import br.dsc.upe.poli.basicas.Login;
import br.dsc.upe.poli.dao.UsuarioDAO;

public class LoginAluno implements LogicaDeNegocio{

	@Override
	public void execute(HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		
		String login = request.getParameter("login");
		String senha =  request.getParameter("senha");
		
		Login login_ = new Login();
		login_.setLogin(login);
		login_.setSenha(senha);
		
		UsuarioDAO usuarioDAO = new UsuarioDAO();
		
		if(usuarioDAO.validacao(login_)){
			RequestDispatcher requestDispatcher = request.getRequestDispatcher("bemVindo.jsp");
			requestDispatcher.forward(request, response);

		}else{
			RequestDispatcher requestDispatcher = request.getRequestDispatcher("cadastro.html");
			requestDispatcher.forward(request, response);

		}
			
		
		
	}

}
