package br.ufscar.filter;

import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import javax.servlet.ServletException;
import javax.servlet.FilterChain;
import java.io.IOException;

@WebFilter(filterName="filterAuth")
public class Auth extends BaseFilter {

    public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {
        HttpServletRequest request = (HttpServletRequest) req;
        HttpServletResponse response = (HttpServletResponse) res;
        HttpSession session = request.getSession(false);
        session.setMaxInactiveInterval(120);
        String loginURI = request.getContextPath() + "/login";

        System.out.println(loginURI);

        boolean loggedIn = session != null && session.getAttribute("authUserId") != null;
        boolean loginRequest = request.getRequestURI().equals(loginURI);

        if (loggedIn || loginRequest) {
            chain.doFilter(request, response);
        } else {
            response.sendRedirect(loginURI);
        }
    }
}
@@ -871,47 +871,8 @@
 %22;%0A%0A
-        System.out.println(loginURI);%0A%0A
     

remove println