fix(DevWeb): Import static files
@@ -1,34 +0,0 @@
|
|||||||
/*
|
|
||||||
* IndexServlet.java, 20/03/2024
|
|
||||||
* UPPA M1 TI 2023-2024
|
|
||||||
* Pas de copyright, aucun droits
|
|
||||||
*/
|
|
||||||
|
|
||||||
package uppa.project.servlet;
|
|
||||||
|
|
||||||
import jakarta.servlet.ServletException;
|
|
||||||
import jakarta.servlet.annotation.WebServlet;
|
|
||||||
import jakarta.servlet.http.HttpServlet;
|
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
@WebServlet(name = "indexServlet", value = "/")
|
|
||||||
public class IndexServlet extends HttpServlet {
|
|
||||||
|
|
||||||
public void init() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
|
|
||||||
|
|
||||||
if (request.getSession().getAttribute("user") != null) {
|
|
||||||
response.sendRedirect(request.getContextPath() + "/main-menu");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
response.sendRedirect(request.getContextPath() + "/login");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void destroy() {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -38,43 +38,6 @@ public class RegisterServlet extends HttpServlet {
|
|||||||
request.getRequestDispatcher("/WEB-INF/views/register.jsp").forward(request, response);
|
request.getRequestDispatcher("/WEB-INF/views/register.jsp").forward(request, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
|
||||||
String username = request.getParameter("username");
|
|
||||||
String email = request.getParameter("email");
|
|
||||||
String birthdate = request.getParameter("birthdate");
|
|
||||||
System.out.println(birthdate);
|
|
||||||
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
|
|
||||||
Date birth;
|
|
||||||
try {
|
|
||||||
birth = formatter.parse(birthdate);
|
|
||||||
} catch (ParseException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
System.out.println("birth: " + birth);
|
|
||||||
String gender = request.getParameter("gender");
|
|
||||||
String password = request.getParameter("password");
|
|
||||||
String confirmPassword = request.getParameter("confirmPassword");
|
|
||||||
if (!password.equals(confirmPassword)) {
|
|
||||||
response.sendRedirect(request.getContextPath() + "/register?error=matching-password");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
createAccount(username, email, password, birth, gender);
|
|
||||||
response.sendRedirect(request.getContextPath() + "/login?success=account-created");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void createAccount(String username, String email, String password, Date birth, String gender){
|
|
||||||
em.getTransaction().begin();
|
|
||||||
try{
|
|
||||||
DAO_JPA_User daoJpaUser = new DAO_JPA_User();
|
|
||||||
User user = new User(username, email, password, birth, User.getGender(gender));
|
|
||||||
daoJpaUser.create(user);
|
|
||||||
em.getTransaction().commit();
|
|
||||||
} catch (DAOException | IllegalArgumentException e) {
|
|
||||||
em.getTransaction().rollback();
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void destroy() {
|
public void destroy() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,47 +0,0 @@
|
|||||||
package uppa.project.servlet.api.img;
|
|
||||||
|
|
||||||
import jakarta.servlet.annotation.WebServlet;
|
|
||||||
import jakarta.servlet.http.HttpServlet;
|
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.OutputStream;
|
|
||||||
|
|
||||||
@WebServlet(name = "imgGetterServlet", value = "/api/imgGet")
|
|
||||||
public class ImgGetterServlet extends HttpServlet {
|
|
||||||
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
|
||||||
// Récupérer le nom de l'image à partir de la requête
|
|
||||||
String imgName = request.getParameter("imgName");
|
|
||||||
|
|
||||||
// Vérifier si le nom de l'image est fourni
|
|
||||||
if (imgName != null && !imgName.isEmpty()) {
|
|
||||||
// Récupérer le chemin complet de l'image (remplacez "path_to_your_images_folder" par le chemin réel)
|
|
||||||
String imagePath = request.getRequestDispatcher("/img/" + imgName).toString();
|
|
||||||
|
|
||||||
// Ouvrir un flux d'entrée vers le fichier image
|
|
||||||
try (InputStream inputStream = getServletContext().getResourceAsStream(imagePath)) {
|
|
||||||
if (inputStream != null) {
|
|
||||||
// Récupérer le flux de sortie de la réponse HTTP
|
|
||||||
OutputStream outputStream = response.getOutputStream();
|
|
||||||
|
|
||||||
// Lire les données de l'image et écrire dans le flux de sortie de la réponse
|
|
||||||
byte[] buffer = new byte[1024];
|
|
||||||
int bytesRead;
|
|
||||||
while ((bytesRead = inputStream.read(buffer)) != -1) {
|
|
||||||
outputStream.write(buffer, 0, bytesRead);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Flusher le flux de sortie
|
|
||||||
outputStream.flush();
|
|
||||||
} else {
|
|
||||||
// Si l'image n'est pas trouvée, retourner une réponse 404 (non trouvé)
|
|
||||||
response.sendError(HttpServletResponse.SC_NOT_FOUND);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Si le nom de l'image n'est pas fourni, retourner une réponse 400 (mauvaise requête)
|
|
||||||
response.sendError(HttpServletResponse.SC_BAD_REQUEST);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -7,9 +7,9 @@
|
|||||||
--%>
|
--%>
|
||||||
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
|
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
|
||||||
|
|
||||||
<style><%@include file="../static/css/navbar.css"%></style>
|
<style><%@include file="/static/css/navbar.css"%></style>
|
||||||
<nav>
|
<nav>
|
||||||
<a href="index"><img src="${pageContext.request.contextPath}/api/imgGet?imgName=CardRushLogo.png" alt="Logo CardsRush"> </a>
|
<a href="index"><img src="${pageContext.request.contextPath}/static/img/CardsRushLogo.png" alt="Logo CardsRush"> </a>
|
||||||
<p>
|
<p>
|
||||||
username: <!-- Récuperer le nom utilisateur --> <br/>
|
username: <!-- Récuperer le nom utilisateur --> <br/>
|
||||||
best score: <!-- Récuperer le meilleur score -->
|
best score: <!-- Récuperer le meilleur score -->
|
||||||
|
|||||||
@@ -1,16 +1,8 @@
|
|||||||
<%@ page import="uppa.project.pojo.User" %>
|
s<%@ page import="uppa.project.pojo.User" %>
|
||||||
<%@ page import="uppa.project.pojo.Game" %>
|
<%@ page import="uppa.project.pojo.Game" %>
|
||||||
<%@ page import="uppa.project.pojo.Deck" %>
|
<%@ page import="uppa.project.pojo.Deck" %>
|
||||||
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
|
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
|
||||||
|
|
||||||
<%--
|
|
||||||
Created by IntelliJ IDEA.
|
|
||||||
User: kmitr
|
|
||||||
Date: 19/03/2024
|
|
||||||
Time: 15:47
|
|
||||||
To change this template use File | Settings | File Templates.
|
|
||||||
--%>
|
|
||||||
|
|
||||||
<div id="newGameModal" class="modal-wrapper" style="display: none">
|
<div id="newGameModal" class="modal-wrapper" style="display: none">
|
||||||
<div class="modal">
|
<div class="modal">
|
||||||
<a href="#close" title="Close" class="close">×</a>
|
<a href="#close" title="Close" class="close">×</a>
|
||||||
|
|||||||
@@ -5,13 +5,7 @@
|
|||||||
<%@ page import="java.util.Date" %>
|
<%@ page import="java.util.Date" %>
|
||||||
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
|
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
|
||||||
|
|
||||||
<%--
|
|
||||||
Created by IntelliJ IDEA.
|
|
||||||
User: kmitr
|
|
||||||
Date: 26/03/2024
|
|
||||||
Time: 11:05
|
|
||||||
To change this template use File | Settings | File Templates.
|
|
||||||
--%>
|
|
||||||
<%--TODO: adapter les deux lignes suivante pour ne pas vérifier la valeur nulle--%>
|
<%--TODO: adapter les deux lignes suivante pour ne pas vérifier la valeur nulle--%>
|
||||||
<% User user = (User) session.getAttribute("user") != null ? (User) session.getAttribute("user") : new User("toto", "toto@gmail.com", "totopassword", new Date(), User.Gender.MALE); %>
|
<% User user = (User) session.getAttribute("user") != null ? (User) session.getAttribute("user") : new User("toto", "toto@gmail.com", "totopassword", new Date(), User.Gender.MALE); %>
|
||||||
<% ArrayList<Game> games = (ArrayList<Game>) request.getAttribute("games") != null ? (ArrayList<Game>) request.getAttribute("games") : new ArrayList<Game>() ; %>
|
<% ArrayList<Game> games = (ArrayList<Game>) request.getAttribute("games") != null ? (ArrayList<Game>) request.getAttribute("games") : new ArrayList<Game>() ; %>
|
||||||
|
|||||||
@@ -1,16 +0,0 @@
|
|||||||
var cb = document.querySelectorAll(".close");
|
|
||||||
for (i = 0; i < cb.length; i++) {
|
|
||||||
cb[i].addEventListener("click", function() {
|
|
||||||
var dia = this.parentNode.parentNode; /* You need to update this part if you change level of close button */
|
|
||||||
dia.style.display = "none";
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
var mt = document.querySelectorAll(".modal-toggle");
|
|
||||||
for (i = 0; i < mt.length; i++) {
|
|
||||||
mt[i].addEventListener("click", function() {
|
|
||||||
var targetId = this.getAttribute("data-target");
|
|
||||||
var target = document.querySelector(targetId);
|
|
||||||
target.style.display = "block";
|
|
||||||
});
|
|
||||||
}
|
|
||||||
@@ -9,6 +9,9 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Forgotten Password</title>
|
<title>Forgotten Password</title>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<%-- <link href="${pageContext.request.contextPath}/static/css/forgotten-password.css" rel="stylesheet">--%>
|
||||||
|
<script src="${pageContext.request.contextPath}/static/js/forgotten-password.js" defer></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<main>
|
<main>
|
||||||
@@ -26,5 +29,4 @@
|
|||||||
<%}%>
|
<%}%>
|
||||||
</main>
|
</main>
|
||||||
</body>
|
</body>
|
||||||
<script defer type="module"><%@include file="../static/js/forgotten-password.js"%></script>
|
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -3,7 +3,8 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title> Cards Rush - Connexion</title>
|
<title> Cards Rush - Connexion</title>
|
||||||
<style><%@include file="../static/css/login.css" %></style>
|
<link href="${pageContext.request.contextPath}/static/css/login.css" rel="stylesheet">
|
||||||
|
<script src="${pageContext.request.contextPath}/static/js/login.js" defer></script>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
@@ -35,8 +36,5 @@
|
|||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
<script defer type="module"><%@include file="../static/js/login.js" %></script>
|
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -5,6 +5,9 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Cards Rush</title>
|
<title>Cards Rush</title>
|
||||||
|
<%-- <link href="${pageContext.request.contextPath}/static/css/main-menu.css" rel="stylesheet">--%>
|
||||||
|
<script src="${pageContext.request.contextPath}/static/js/modal.js" defer></script>
|
||||||
|
<script src="${pageContext.request.contextPath}/static/js/new-game.js" defer></script>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
@@ -21,6 +24,4 @@
|
|||||||
<%@include file="../components/new-game.jsp"%>
|
<%@include file="../components/new-game.jsp"%>
|
||||||
<%@include file="../components/statistics.jsp"%>
|
<%@include file="../components/statistics.jsp"%>
|
||||||
</body>
|
</body>
|
||||||
<script defer type="text/javascript"><%@include file="../static/js/modal.js"%></script>
|
|
||||||
<script defer type="text/javascript"><%@include file="../static/js/new-game.js"%></script>
|
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -3,7 +3,8 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Register</title>
|
<title>Register</title>
|
||||||
<style><%@include file="../static/css/login.css"%></style>
|
<link href="${pageContext.request.contextPath}/static/css/login.css" rel="stylesheet">
|
||||||
|
<script src="${pageContext.request.contextPath}/static/js/register.js" defer></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
@@ -51,5 +52,4 @@
|
|||||||
</main>
|
</main>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
<script defer type="module"><%@include file="../static/js/register.js"%></script>
|
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -1,23 +1,20 @@
|
|||||||
<%@ page import="uppa.project.dao.jpa.DAO_JPA_RecoveryPasswordToken" %>
|
<%@ page import="uppa.project.dao.jpa.DAO_JPA_RecoveryPasswordToken" %>
|
||||||
<%@ page import="uppa.project.pojo.RecoveryPasswordToken" %>
|
<%@ page import="uppa.project.pojo.RecoveryPasswordToken" %>
|
||||||
<%@ page import="uppa.project.dao.DAOException" %>
|
<%@ page import="uppa.project.dao.DAOException" %>
|
||||||
<%--
|
|
||||||
Created by IntelliJ IDEA.
|
|
||||||
User: kmitr
|
|
||||||
Date: 22/03/2024
|
|
||||||
Time: 13:48
|
|
||||||
To change this template use File | Settings | File Templates.
|
|
||||||
--%>
|
|
||||||
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
|
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Récupération du mot de passe</title>
|
<title>Récupération du mot de passe</title>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<%-- <link href="${pageContext.request.contextPath}/static/css/reset-password.css" rel="stylesheet">--%>
|
||||||
|
<script src="${pageContext.request.contextPath}/static/js/reset-password.js" defer></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<main>
|
<main>
|
||||||
<jsp:include page="../components/navbar.jsp"/>
|
<jsp:include page="../components/navbar.jsp"/>
|
||||||
<h1>Récupération du mot de passe</h1>
|
<h1>Récupération du mot de passe</h1>
|
||||||
<form id="resetPasswordForm" action="reset-password" method="post">
|
<form id="resetPasswordForm" action="${pageContext.request.contextPath}/reset-password" method="post">
|
||||||
<label for="newPassword">Nouveau mot de passe</label>
|
<label for="newPassword">Nouveau mot de passe</label>
|
||||||
<input type="password" id="newPassword" name="newPassword" required>
|
<input type="password" id="newPassword" name="newPassword" required>
|
||||||
<label for="confirmPassword">Confirmer le mot de passe</label>
|
<label for="confirmPassword">Confirmer le mot de passe</label>
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 2.6 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 123 B After Width: | Height: | Size: 123 B |
|
Before Width: | Height: | Size: 123 B After Width: | Height: | Size: 123 B |
@@ -0,0 +1,16 @@
|
|||||||
|
let cb = document.querySelectorAll(".close");
|
||||||
|
for (let i = 0; i < cb.length; i++) {
|
||||||
|
cb[i].addEventListener("click", function() {
|
||||||
|
const dia = this.parentNode.parentNode; /* You need to update this part if you change level of close button */
|
||||||
|
dia.style.display = "none";
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
let mt = document.querySelectorAll(".modal-toggle");
|
||||||
|
for (let i = 0; i < mt.length; i++) {
|
||||||
|
mt[i].addEventListener("click", function() {
|
||||||
|
const targetId = this.getAttribute("data-target");
|
||||||
|
const target = document.querySelector(targetId);
|
||||||
|
target.style.display = "block";
|
||||||
|
});
|
||||||
|
}
|
||||||