Added URI fields and added cookie authentication
This commit is contained in:
parent
99c67eaaba
commit
8e56ff406a
16 changed files with 133 additions and 71 deletions
|
|
@ -15,15 +15,29 @@ import java.io.IOException;
|
|||
import java.sql.SQLException;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@WebServlet("/login")
|
||||
|
||||
@WebServlet(LoginServlet.URI)
|
||||
public class LoginServlet extends ZalleryServlet {
|
||||
private static Logger logger = LogUtil.getLogger();
|
||||
|
||||
public static final String URI = "/login";
|
||||
private static final String JSP_FILE = "page_login.jsp";
|
||||
|
||||
|
||||
public void doGet(HttpServletRequest request, HttpServletResponse response, DBConnection db) throws ServletException, IOException {
|
||||
include(JSP_FILE, request, response);
|
||||
public void doGet(HttpServletRequest request, HttpServletResponse response, DBConnection db) throws ServletException, IOException, SQLException {
|
||||
// User already logged in?
|
||||
User user = AuthenticationManager.getUserSession(request.getSession());
|
||||
|
||||
// Authenticate with cookies
|
||||
if (user == null)
|
||||
user = AuthenticationManager.authenticate(db, request);
|
||||
|
||||
// Forward user
|
||||
if (user != null) {
|
||||
include(JSP_FILE, request, response);
|
||||
} else {
|
||||
redirect(GalleryServlet.URI, request, response);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue