public void doPost (HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String requestUsername = request.getParameter("username");
        String requestPassword = request.getParameter("password");

        Map <String, Object> pageVariables = new HashMap<>();
        String path = request.getPathInfo();

        if(path.equals("/auth.html") || path.equals("/auth")){
            if (accountService.authorize(requestUsername, requestPassword)) {
                response.sendRedirect("/user");
                pageVariables.put("serverTime", getTime());
                pageVariables.put("refreshPeriod", "1000");
            } else {
                pageVariables.put("errorMessage", "Login or password was incorrect!");
                response.getWriter().println(PageGenerator.getPage("auth.html", pageVariables));
            }
        }
        if(path.equals("/reg.html") || path.equals("/reg")){
            if(requestUsername.isEmpty() || requestPassword.isEmpty()){
                pageVariables.put("registrationMessage", "Login or password was empty! Error!");
            } else {
                if(accountService.register(requestUsername, requestPassword)){
                    HttpSession session = request.getSession();
                    session.setAttribute("userId", accountService.getUserId(requestUsername));
                    pageVariables.put("registrationMessage", "User " + requestUsername + " was registered!");
                } else {
                    pageVariables.put("registrationMessage", "User " + requestUsername + " is already registered! Try another login!");
                }
            }
            response.getWriter().println(PageGenerator.getPage("reg.html", pageVariables));
        }
    }