diff --git a/.gradle/7.4.1/checksums/checksums.lock b/.gradle/7.4.1/checksums/checksums.lock index f0ed0076b5d6f718f7d50f2d63732c9eb6af926a..69ac7cc6800f6ef47e8d982da859b7bf58ee0002 100644 Binary files a/.gradle/7.4.1/checksums/checksums.lock and b/.gradle/7.4.1/checksums/checksums.lock differ diff --git a/.gradle/7.4.1/dependencies-accessors/dependencies-accessors.lock b/.gradle/7.4.1/dependencies-accessors/dependencies-accessors.lock index bb87dff84e19540605f8f6f78f8d7b548a259592..1f8387a43dd79bd78acbc23430321c266bcc7400 100644 Binary files a/.gradle/7.4.1/dependencies-accessors/dependencies-accessors.lock and b/.gradle/7.4.1/dependencies-accessors/dependencies-accessors.lock differ diff --git a/.gradle/7.4.1/executionHistory/executionHistory.bin b/.gradle/7.4.1/executionHistory/executionHistory.bin index 04af598603e3c0dbece9c163e1e4bf01adcf8e33..35e8581948a781443b8cef4ca765a0364c880014 100644 Binary files a/.gradle/7.4.1/executionHistory/executionHistory.bin and b/.gradle/7.4.1/executionHistory/executionHistory.bin differ diff --git a/.gradle/7.4.1/executionHistory/executionHistory.lock b/.gradle/7.4.1/executionHistory/executionHistory.lock index 995173ed5aa440edfdd9a82c5ac07216e8ffe9e9..cef93bef131fdd8b31acefb7e900e10eb335eec9 100644 Binary files a/.gradle/7.4.1/executionHistory/executionHistory.lock and b/.gradle/7.4.1/executionHistory/executionHistory.lock differ diff --git a/.gradle/7.4.1/fileHashes/fileHashes.bin b/.gradle/7.4.1/fileHashes/fileHashes.bin index db61e0d58fa57d2ddccbe1e0318afea490950022..e5ddb6ed42a60d309e2933288ccf7f4b6ac05b6e 100644 Binary files a/.gradle/7.4.1/fileHashes/fileHashes.bin and b/.gradle/7.4.1/fileHashes/fileHashes.bin differ diff --git a/.gradle/7.4.1/fileHashes/fileHashes.lock b/.gradle/7.4.1/fileHashes/fileHashes.lock index 611c9933fd26603af51762bc4356bf810ac5a488..0ad435fcb789595c07728a637f4770f0302f319c 100644 Binary files a/.gradle/7.4.1/fileHashes/fileHashes.lock and b/.gradle/7.4.1/fileHashes/fileHashes.lock differ diff --git a/.gradle/7.4.1/fileHashes/resourceHashesCache.bin b/.gradle/7.4.1/fileHashes/resourceHashesCache.bin index 996bef414819088bf35691fc12481d77cc318c62..5f3a57225ac140d2c3fb1f810ba468e96e2cc996 100644 Binary files a/.gradle/7.4.1/fileHashes/resourceHashesCache.bin and b/.gradle/7.4.1/fileHashes/resourceHashesCache.bin differ diff --git a/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/.gradle/buildOutputCleanup/buildOutputCleanup.lock index 544a8cfe00c4b509b730ed4051039f37a9f24180..ffeaeabace06d3c15c083a75d750e0b5a3f6c538 100644 Binary files a/.gradle/buildOutputCleanup/buildOutputCleanup.lock and b/.gradle/buildOutputCleanup/buildOutputCleanup.lock differ diff --git a/.gradle/file-system.probe b/.gradle/file-system.probe index 11eb4f4d3083c13c347fb8db56ee66ae61fb5d7d..c802129a9bf9b10027170f3fc7e7595e7e7721be 100644 Binary files a/.gradle/file-system.probe and b/.gradle/file-system.probe differ diff --git a/bin/default/.gradle/7.4.1/executionHistory/executionHistory.bin b/bin/default/.gradle/7.4.1/executionHistory/executionHistory.bin index 8cbe002a377e025f687abf243c88d0cfe6664869..35e8581948a781443b8cef4ca765a0364c880014 100644 Binary files a/bin/default/.gradle/7.4.1/executionHistory/executionHistory.bin and b/bin/default/.gradle/7.4.1/executionHistory/executionHistory.bin differ diff --git a/bin/default/.gradle/7.4.1/executionHistory/executionHistory.lock b/bin/default/.gradle/7.4.1/executionHistory/executionHistory.lock index 07dc3df6469b578746f5d7b8e2ad6bfee5687617..47c352e424993d2d75c25feb45748a6764a0db99 100644 Binary files a/bin/default/.gradle/7.4.1/executionHistory/executionHistory.lock and b/bin/default/.gradle/7.4.1/executionHistory/executionHistory.lock differ diff --git a/bin/default/.gradle/7.4.1/fileHashes/fileHashes.bin b/bin/default/.gradle/7.4.1/fileHashes/fileHashes.bin index 34e492acc14032a7e9ac139c5122e112b7dbcdb6..e5ddb6ed42a60d309e2933288ccf7f4b6ac05b6e 100644 Binary files a/bin/default/.gradle/7.4.1/fileHashes/fileHashes.bin and b/bin/default/.gradle/7.4.1/fileHashes/fileHashes.bin differ diff --git a/bin/default/.gradle/7.4.1/fileHashes/fileHashes.lock b/bin/default/.gradle/7.4.1/fileHashes/fileHashes.lock index 8b24fd074b3598c46c3a0036992aadb99b32ea69..ee27618a9d1963edb5db0bdf6b674695f364ba70 100644 Binary files a/bin/default/.gradle/7.4.1/fileHashes/fileHashes.lock and b/bin/default/.gradle/7.4.1/fileHashes/fileHashes.lock differ diff --git a/bin/default/.gradle/7.4.1/fileHashes/resourceHashesCache.bin b/bin/default/.gradle/7.4.1/fileHashes/resourceHashesCache.bin index 8ca30f9b7c8a54cade3d51031474b9938fb8aa20..5f3a57225ac140d2c3fb1f810ba468e96e2cc996 100644 Binary files a/bin/default/.gradle/7.4.1/fileHashes/resourceHashesCache.bin and b/bin/default/.gradle/7.4.1/fileHashes/resourceHashesCache.bin differ diff --git a/bin/default/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/bin/default/.gradle/buildOutputCleanup/buildOutputCleanup.lock index 6479b6b9eab667cd00b4bbcdf93541a747132199..ceb3eca9b9ba8c94d91be1b60973ab6fa8522797 100644 Binary files a/bin/default/.gradle/buildOutputCleanup/buildOutputCleanup.lock and b/bin/default/.gradle/buildOutputCleanup/buildOutputCleanup.lock differ diff --git a/bin/default/.gradle/file-system.probe b/bin/default/.gradle/file-system.probe index 11eb4f4d3083c13c347fb8db56ee66ae61fb5d7d..bb51e60d143eaca6529145f9445106b6aeaac3ff 100644 Binary files a/bin/default/.gradle/file-system.probe and b/bin/default/.gradle/file-system.probe differ diff --git a/bin/default/build/resources/main/views/login.ftl b/bin/default/build/resources/main/views/login.ftl new file mode 100644 index 0000000000000000000000000000000000000000..fe97a5871a4f67016dd81e5eecd50862a7496daf --- /dev/null +++ b/bin/default/build/resources/main/views/login.ftl @@ -0,0 +1,18 @@ +<#ftl encoding="utf-8"> + + +<body xmlns="http://www.w3.org/1999/html"> + + + +<form method="post" action="/login"> + <label for="userName">Nom d'utilisateur</label> + <input name="userName"> + <label for="password">Mot de passe</label> + <input name="password"> + <button type="submit" placeholder="Supprimer...">Envoyer</button> +</form> + +</body> + +</html> diff --git a/bin/default/build/resources/main/views/profs.ftl b/bin/default/build/resources/main/views/profs.ftl index 39fd9bfb2db5721153d4fd8bac3265036f0ac18a..c4f1c138178b1bb49f181757150eb17833fa6bc7 100644 --- a/bin/default/build/resources/main/views/profs.ftl +++ b/bin/default/build/resources/main/views/profs.ftl @@ -11,8 +11,10 @@ </ul> -<form method="post" action="prof/delete"> +<form method="post" action="profs/delete"> + <label for="id">id</label> <input name="id"> + <button type="submit" placeholder="Supprimer...">Envoyer</button> </form> </body> diff --git a/bin/default/build/tmp/compileJava/previous-compilation-data.bin b/bin/default/build/tmp/compileJava/previous-compilation-data.bin index ff3746184e3cc77428baebcde70f425c0559a74a..f2298fea74fa4c5295756c6ca6f41832fb77233f 100644 Binary files a/bin/default/build/tmp/compileJava/previous-compilation-data.bin and b/bin/default/build/tmp/compileJava/previous-compilation-data.bin differ diff --git a/bin/default/src/com/uca/StartServer.class b/bin/default/src/com/uca/StartServer.class index f735b2b08e2c0019c00897c4f83c1f0828d90a06..dd9c388b6ede8a6bda8fc82a6b870b03040c2ac9 100644 Binary files a/bin/default/src/com/uca/StartServer.class and b/bin/default/src/com/uca/StartServer.class differ diff --git a/bin/default/src/com/uca/core/ProfCore.class b/bin/default/src/com/uca/core/ProfCore.class index b62e424c8c912af31675fe45ea783bd3042a423a..4b6a2dba88accf11cdca004e28671b8b8c0556c4 100644 Binary files a/bin/default/src/com/uca/core/ProfCore.class and b/bin/default/src/com/uca/core/ProfCore.class differ diff --git a/bin/default/src/com/uca/dao/ProfDAO.class b/bin/default/src/com/uca/dao/ProfDAO.class index ffebcc69ccc12ef7b068aa8f9df3e25fbe243932..5898baaf7266b0df3b9ceb1a1a49e2c31d4ac537 100644 Binary files a/bin/default/src/com/uca/dao/ProfDAO.class and b/bin/default/src/com/uca/dao/ProfDAO.class differ diff --git a/bin/default/src/com/uca/dao/_Initializer.class b/bin/default/src/com/uca/dao/_Initializer.class index 0f8d5d6e860d6fbd3f640c5475b82ee6c66abc95..c3a446c454f6fba79cf4ee4d2b8b3aa7f5a66d3b 100644 Binary files a/bin/default/src/com/uca/dao/_Initializer.class and b/bin/default/src/com/uca/dao/_Initializer.class differ diff --git a/bin/default/src/com/uca/entity/ProfEntity.class b/bin/default/src/com/uca/entity/ProfEntity.class index 24614c9f039378ff1b6aceaac6cb52d0fe8639f9..a355a4abf74de957b8833c6fdcf6583232f8a7cf 100644 Binary files a/bin/default/src/com/uca/entity/ProfEntity.class and b/bin/default/src/com/uca/entity/ProfEntity.class differ diff --git a/bin/default/src/com/uca/gui/LoginGUI.class b/bin/default/src/com/uca/gui/LoginGUI.class new file mode 100644 index 0000000000000000000000000000000000000000..6195f68438b28d8c7a5e0d97417b64a64935665d Binary files /dev/null and b/bin/default/src/com/uca/gui/LoginGUI.class differ diff --git a/bin/default/src/main/resources/views/login.ftl b/bin/default/src/main/resources/views/login.ftl new file mode 100644 index 0000000000000000000000000000000000000000..fe97a5871a4f67016dd81e5eecd50862a7496daf --- /dev/null +++ b/bin/default/src/main/resources/views/login.ftl @@ -0,0 +1,18 @@ +<#ftl encoding="utf-8"> + + +<body xmlns="http://www.w3.org/1999/html"> + + + +<form method="post" action="/login"> + <label for="userName">Nom d'utilisateur</label> + <input name="userName"> + <label for="password">Mot de passe</label> + <input name="password"> + <button type="submit" placeholder="Supprimer...">Envoyer</button> +</form> + +</body> + +</html> diff --git a/bin/default/src/main/resources/views/profs.ftl b/bin/default/src/main/resources/views/profs.ftl index 39fd9bfb2db5721153d4fd8bac3265036f0ac18a..c4f1c138178b1bb49f181757150eb17833fa6bc7 100644 --- a/bin/default/src/main/resources/views/profs.ftl +++ b/bin/default/src/main/resources/views/profs.ftl @@ -11,8 +11,10 @@ </ul> -<form method="post" action="prof/delete"> +<form method="post" action="profs/delete"> + <label for="id">id</label> <input name="id"> + <button type="submit" placeholder="Supprimer...">Envoyer</button> </form> </body> diff --git a/build/classes/java/main/com/uca/StartServer.class b/build/classes/java/main/com/uca/StartServer.class index 7dbe4917a3184289e49e495f2d89fb151c3f8809..c2b2083ec570c97cded990f1ccd4e49747bef6b4 100644 Binary files a/build/classes/java/main/com/uca/StartServer.class and b/build/classes/java/main/com/uca/StartServer.class differ diff --git a/build/classes/java/main/com/uca/core/ProfCore.class b/build/classes/java/main/com/uca/core/ProfCore.class index 55bceb62406e5bc6f4058e5700351a387f512b1c..e954f61de00386f8f86b266371558dea47fc0d88 100644 Binary files a/build/classes/java/main/com/uca/core/ProfCore.class and b/build/classes/java/main/com/uca/core/ProfCore.class differ diff --git a/build/classes/java/main/com/uca/dao/ProfDAO.class b/build/classes/java/main/com/uca/dao/ProfDAO.class index 2099620acf80af0590481fb32521b5dabdc769b3..681464cc4330924b00bcebdeb4bbe3923adbe6dc 100644 Binary files a/build/classes/java/main/com/uca/dao/ProfDAO.class and b/build/classes/java/main/com/uca/dao/ProfDAO.class differ diff --git a/build/classes/java/main/com/uca/dao/_Initializer.class b/build/classes/java/main/com/uca/dao/_Initializer.class index c102f8b94675252a73e7adadc3236fcb012ee7e0..4a86727ac890446e5690cd60f602c607f658f222 100644 Binary files a/build/classes/java/main/com/uca/dao/_Initializer.class and b/build/classes/java/main/com/uca/dao/_Initializer.class differ diff --git a/build/classes/java/main/com/uca/entity/ProfEntity.class b/build/classes/java/main/com/uca/entity/ProfEntity.class index ef6b92ff957c7f717207c4d447411befe85eca71..c0f413871840eca68f6342bc6a53417ee54499c2 100644 Binary files a/build/classes/java/main/com/uca/entity/ProfEntity.class and b/build/classes/java/main/com/uca/entity/ProfEntity.class differ diff --git a/build/classes/java/main/com/uca/gui/LoginGUI.class b/build/classes/java/main/com/uca/gui/LoginGUI.class new file mode 100644 index 0000000000000000000000000000000000000000..be42bf85bf82b8163edf9686882822674c115a1e Binary files /dev/null and b/build/classes/java/main/com/uca/gui/LoginGUI.class differ diff --git a/build/resources/main/views/login.ftl b/build/resources/main/views/login.ftl new file mode 100644 index 0000000000000000000000000000000000000000..fe97a5871a4f67016dd81e5eecd50862a7496daf --- /dev/null +++ b/build/resources/main/views/login.ftl @@ -0,0 +1,18 @@ +<#ftl encoding="utf-8"> + + +<body xmlns="http://www.w3.org/1999/html"> + + + +<form method="post" action="/login"> + <label for="userName">Nom d'utilisateur</label> + <input name="userName"> + <label for="password">Mot de passe</label> + <input name="password"> + <button type="submit" placeholder="Supprimer...">Envoyer</button> +</form> + +</body> + +</html> diff --git a/build/tmp/compileJava/previous-compilation-data.bin b/build/tmp/compileJava/previous-compilation-data.bin index aa1948a34a4e0bb3a101d1588261bf4331667963..f2298fea74fa4c5295756c6ca6f41832fb77233f 100644 Binary files a/build/tmp/compileJava/previous-compilation-data.bin and b/build/tmp/compileJava/previous-compilation-data.bin differ diff --git a/src/com/uca/StartServer.java b/src/com/uca/StartServer.java index 378f96f5a1b7951bae124972efa57c49dcdc8207..394ecb85f640d9b9aa1290c5ae36b920b4aad39c 100644 --- a/src/com/uca/StartServer.java +++ b/src/com/uca/StartServer.java @@ -5,18 +5,22 @@ import com.uca.gui.*; import com.uca.core.*; import com.uca.entity.*; import java.sql.*; +import java.util.*; import static spark.Spark.*; public class StartServer { //.\gradlew run + public static boolean authentified = false; + public static void displayLocalHost(int portNb, String suffix) { System.out.println("http://localhost:"+portNb+"/"+suffix); } public static void main(String[] args) { + int portNb = 8081; //Configure Spark staticFiles.location("/static/"); @@ -33,7 +37,16 @@ public class StartServer { displayLocalHost(portNb, "profs"); get("/profs", (req, res) -> { - return ProfGUI.getAllProfs(); + if (authentified) + { + return ProfGUI.getAllProfs(); + } + else + { + res.redirect("/login"); + return null; + } + }); post("/profs/delete",(req,res) -> { @@ -42,6 +55,34 @@ public class StartServer { return null; }); + + displayLocalHost(portNb, "login"); + get("/login",(req,res)->{ + return LoginGUI.getConnectionPage(); + }); + + post("/login",(req,res)->{ + String username = req.queryParams("userName"); + String password = req.queryParams("password"); + List<ProfEntity> profs = Core.Prof.getAll(); + ProfEntity found = null; + for (ProfEntity prof: profs) { + if (prof.getUserName().compareTo(username) == 0){ + found = prof; + break; + } + } + if (found != null) { + if (found.getPassword().compareTo(password) == 0) { + authentified = true; + res.redirect("/profs"); + System.out.println(found); + return null; + } + } + + return "<!DOCTYPE html><html>Incorrect</html>"; + }); } } \ No newline at end of file diff --git a/src/com/uca/core/ProfCore.java b/src/com/uca/core/ProfCore.java index f8c5f12332663438f82e4b251ff2f4b03ed75052..0301eec092ad015d7f7929e0796eacc061d11584 100644 --- a/src/com/uca/core/ProfCore.java +++ b/src/com/uca/core/ProfCore.java @@ -13,11 +13,12 @@ public class ProfCore extends _DefaultCore<ProfEntity> { super(new ProfDAO()); } - public ProfEntity create(String firstName, String lastName, String userName) { + public ProfEntity create(String firstName, String lastName, String userName, String password) { ProfEntity entity = new ProfEntity(); entity.setFirstName(firstName); entity.setLastName (lastName); entity.setUserName (userName); + entity.setPassword(password); return dao.create(entity); } } diff --git a/src/com/uca/dao/ProfDAO.java b/src/com/uca/dao/ProfDAO.java index bb618cfa0a087b9dc6bf60d82a1e011b9a2d4dfa..d9c467f30c076c329ba0683a6347c1ce67f55915 100644 --- a/src/com/uca/dao/ProfDAO.java +++ b/src/com/uca/dao/ProfDAO.java @@ -13,11 +13,12 @@ public class ProfDAO extends _DefaultDAO<ProfEntity> { @Override public void pushUnsafe(ProfEntity obj) throws Exception { - PreparedStatement stmt = this.connect.prepareStatement("update profs set firstName=?, lastName=?, userName=? where id=?;"); + PreparedStatement stmt = this.connect.prepareStatement("update profs set firstName=?, lastName=?, userName=? , password=? where id=?;"); int idx = 1; stmt.setString(idx++, obj.getFirstName()); stmt.setString(idx++, obj.getLastName()); stmt.setString(idx++, obj.getUserName()); + stmt.setString(idx++, obj.getPassword()); stmt.setInt (idx++, obj.getId()); stmt.executeUpdate(); } @@ -30,6 +31,8 @@ public class ProfDAO extends _DefaultDAO<ProfEntity> { entity.setFirstName(resultSet.getString("firstName")); entity.setLastName(resultSet.getString("lastName")); entity.setUserName(resultSet.getString("userName")); + entity.setPassword(resultSet.getString("password")); + return entity; } } \ No newline at end of file diff --git a/src/com/uca/dao/_Initializer.java b/src/com/uca/dao/_Initializer.java index 745ec227cae70000c7b34982b86076e5ad3d290d..4b8361cd5deb33070374a029396d7acb53aaca8f 100644 --- a/src/com/uca/dao/_Initializer.java +++ b/src/com/uca/dao/_Initializer.java @@ -31,10 +31,10 @@ public class _Initializer { } public static void Init(){ - //DropTable("users"); - //DropTable("profs"); + DropTable("users"); + DropTable("profs"); CreateTable("CREATE TABLE IF NOT EXISTS users (id int primary key auto_increment, firstname varchar(100), lastname varchar(100));"); - CreateTable("CREATE TABLE IF NOT EXISTS profs (id int primary key auto_increment, firstname varchar(100), lastname varchar(100), username varchar(100));"); + CreateTable("CREATE TABLE IF NOT EXISTS profs (id int primary key auto_increment, firstname varchar(100), lastname varchar(100), username varchar(100), password varchar(100));"); //CreateTable("CREATE TABLE IF NOT EXISTS eleves(id int primary key auto_increment, firstname varchar(100), lastname varchar(100), nomClasse varchar(100), dateNaissance varchar(10));"); //CreateTable("CREATE TABLE IF NOT EXISTS gommettes(id int primary key auto_increment, nom varchar(100), description varchar(100));"); //CreateTable("CREATE TABLE IF NOT EXISTS gommetteAttribs(id int primary key auto_increment, id idEleve, id idProf, raison varchar(500));"); @@ -51,7 +51,7 @@ public class _Initializer { Core.User.create("Terry", "Golo"); Core.User.create("Judas", "Nanas"); - Core.Prof.create("Boris", "OUYA", "DaWarudo"); - Core.Prof.create("Thomas", "TAMAGNAUD", "CéMoiLul"); + Core.Prof.create("Boris", "OUYA", "DaWarudo",""); + Core.Prof.create("Thomas", "TAMAGNAUD", "CéMoiLul","FaisMoiMal"); } } diff --git a/src/com/uca/entity/ProfEntity.java b/src/com/uca/entity/ProfEntity.java index 9fabb71bba0268331e009cfd9b9b2ef073961785..61c08dc549b22284f87e69f8cd3c3f1700146375 100644 --- a/src/com/uca/entity/ProfEntity.java +++ b/src/com/uca/entity/ProfEntity.java @@ -4,8 +4,12 @@ import com.uca.entity.UserEntity; public class ProfEntity extends UserEntity { private String UserName; + private String password; + public String getUserName() { return UserName; } public void setUserName(String value) { UserName = value; } + public void setPassword(String value) { password = value; } + public String getPassword() { return password; } public ProfEntity() { } } diff --git a/src/com/uca/gui/LoginGUI.java b/src/com/uca/gui/LoginGUI.java new file mode 100644 index 0000000000000000000000000000000000000000..e34c2a4561813792e1dbef49d0fa69713d16af97 --- /dev/null +++ b/src/com/uca/gui/LoginGUI.java @@ -0,0 +1,15 @@ +package com.uca.gui; + +import com.uca.core.*; +import freemarker.template.*; +import java.io.*; +import java.util.*; + +public class LoginGUI +{ + public static String getConnectionPage() throws IOException, TemplateException { + + Map<String, Object> input = new HashMap<>(); + return DefaultGUI.getDefaultGUI(input, "login.ftl"); + } +} \ No newline at end of file diff --git a/src/com/uca/gui/ProfGUI.java b/src/com/uca/gui/ProfGUI.java index 595d74737905209dbaa1adb2266a3aa5330ed8f5..30379531e8a402057cf8a6c307862819caab869e 100644 --- a/src/com/uca/gui/ProfGUI.java +++ b/src/com/uca/gui/ProfGUI.java @@ -18,4 +18,7 @@ public class ProfGUI { Core.Prof.delete(Core.Prof.getById(Integer.parseInt(id))); } + + + } diff --git a/src/main/resources/views/login.ftl b/src/main/resources/views/login.ftl new file mode 100644 index 0000000000000000000000000000000000000000..fe97a5871a4f67016dd81e5eecd50862a7496daf --- /dev/null +++ b/src/main/resources/views/login.ftl @@ -0,0 +1,18 @@ +<#ftl encoding="utf-8"> + + +<body xmlns="http://www.w3.org/1999/html"> + + + +<form method="post" action="/login"> + <label for="userName">Nom d'utilisateur</label> + <input name="userName"> + <label for="password">Mot de passe</label> + <input name="password"> + <button type="submit" placeholder="Supprimer...">Envoyer</button> +</form> + +</body> + +</html>