Browse Source

Version Fonctionnelle (SIGN IN avec DB, Test en local sur ports)

Paul Faure 3 years ago
parent
commit
d2a9e18431

+ 5
- 2
.idea/Clavardage.iml View File

@@ -1,8 +1,11 @@
1 1
 <?xml version="1.0" encoding="UTF-8"?>
2
-<module type="JAVA_MODULE" version="4">
2
+<module external.linked.project.id="Clavardage" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="app.insa.clav" external.system.module.version="1.0" type="JAVA_MODULE" version="4">
3 3
   <component name="NewModuleRootManager" inherit-compiler-output="true">
4 4
     <exclude-output />
5
-    <content url="file://$MODULE_DIR$" />
5
+    <content url="file://$MODULE_DIR$">
6
+      <excludeFolder url="file://$MODULE_DIR$/.gradle" />
7
+      <excludeFolder url="file://$MODULE_DIR$/build" />
8
+    </content>
6 9
     <orderEntry type="inheritedJdk" />
7 10
     <orderEntry type="sourceFolder" forTests="false" />
8 11
   </component>

+ 2
- 2
.idea/gradle.xml View File

@@ -8,10 +8,10 @@
8 8
         <option name="testRunner" value="GRADLE" />
9 9
         <option name="distributionType" value="DEFAULT_WRAPPED" />
10 10
         <option name="externalProjectPath" value="$PROJECT_DIR$" />
11
-        <option name="gradleJvm" value="11 (2)" />
11
+        <option name="gradleJvm" value="11" />
12 12
         <option name="modules">
13 13
           <set>
14
-            <option value="$USER_HOME$/Cours/4A/Clavardage" />
14
+            <option value="$PROJECT_DIR$" />
15 15
           </set>
16 16
         </option>
17 17
       </GradleProjectSettings>

+ 0
- 1
.idea/vcs.xml View File

@@ -2,6 +2,5 @@
2 2
 <project version="4">
3 3
   <component name="VcsDirectoryMappings">
4 4
     <mapping directory="$PROJECT_DIR$" vcs="Git" />
5
-    <mapping directory="$USER_HOME$/Cours/4A/Clavardage" vcs="Git" />
6 5
   </component>
7 6
 </project>

+ 29
- 0
src/main/java/app/insa/clav/Core/DataBaseAccess.java View File

@@ -67,6 +67,35 @@ public class DataBaseAccess {
67 67
         return loginAux == null;
68 68
     }
69 69
 
70
+    public boolean LoginExist(String login) {
71
+        String Query = "SELECT * FROM Utilisateurs WHERE login = '" + login + "'";
72
+        System.out.println(Query);
73
+        boolean Ok = false;
74
+        try {
75
+            Statement stmt = con.createStatement();
76
+            ResultSet rs = stmt.executeQuery(Query);
77
+            Ok = rs.next();
78
+        } catch (SQLException throwables) {
79
+            throwables.printStackTrace();
80
+        }
81
+        return Ok;
82
+    }
83
+
84
+    public int getIdFromLogin(String login) {
85
+        String Query = "SELECT id FROM Utilisateurs WHERE login = '" + login + "'";
86
+        int id = -1;
87
+        try {
88
+            Statement stmt = con.createStatement();
89
+            ResultSet rs = stmt.executeQuery(Query);
90
+            if (rs.next()) {
91
+                id = rs.getInt(1);
92
+            }
93
+        } catch (SQLException throwables) {
94
+            throwables.printStackTrace();
95
+        }
96
+        return id;
97
+    }
98
+
70 99
     public int addUtilisateur(String login, String pseudo){
71 100
         String loginAux = null;
72 101
         String preparedQuery = "INSERT INTO Utilisateurs (`login`, `pseudo`,`password`) VALUES (?,?,'pouet')";

+ 1
- 1
src/main/java/app/insa/clav/Main.java View File

@@ -37,7 +37,7 @@ public class Main extends Application{
37 37
         //String ipAdress = arg[0];
38 38
         launch(arg);
39 39
 
40
-        /* while (true){
40
+        /*while (true){
41 41
             Scanner myScan = new Scanner(System.in);
42 42
             System.out.println("Entrez un pseudo svp : ");
43 43
             String pseudo = myScan.nextLine();

+ 2
- 0
src/main/java/app/insa/clav/Reseau/UDPOutput.java View File

@@ -57,7 +57,9 @@ public class UDPOutput{
57 57
             }
58 58
             //InetAddress broadcastAdress = InetAddress.getByAddress("255.255.255.255".getBytes());
59 59
             DatagramPacket packet = new DatagramPacket(buffer,buffer.length,msg.destIP,msg.destPort);
60
+            System.out.println(packet.toString());
60 61
             this.socket.send(packet);
62
+            System.out.println("UDP Packet Sended");
61 63
         }
62 64
         catch (UnknownHostException e){
63 65
             System.out.println("Unknown host dans broadcast address");

+ 6
- 5
src/main/java/app/insa/clav/UIControllers/ConnectionScreenController.java View File

@@ -98,12 +98,13 @@ public class ConnectionScreenController implements Initializable, PropertyChange
98 98
         if (!login.equals("") && !this.isSubmittingIn && !this.isSubmittingUp) {
99 99
             this.isSubmittingIn = true;
100 100
             this.spinnerIn.setVisible(true);
101
-            String pseudo = this.dbAccess.getPseudoFromLogin(login);
102
-            if (pseudo == null){
103
-                this.labelErrorInLogin.setVisible(true);
104
-            }
105
-            else {
101
+            if (this.dbAccess.LoginExist(login)) {
102
+                String pseudo = this.dbAccess.getPseudoFromLogin(login);
103
+                int id = this.dbAccess.getIdFromLogin(login);
104
+                this.model.setUserId(id);
106 105
                 this.model.choosePseudo(pseudo,true);
106
+            } else {
107
+                this.labelErrorInLogin.setVisible(true);
107 108
             }
108 109
         }
109 110
     }

Loading…
Cancel
Save