création admin pour avoir Cheat Code
This commit is contained in:
@@ -48,7 +48,10 @@ public class GestionnaireBDD {
|
||||
"identifiant TEXT UNIQUE NOT NULL, " +
|
||||
"mot_de_passe TEXT NOT NULL)");
|
||||
|
||||
} catch (SQLException e) {
|
||||
try { stmt.execute("ALTER TABLE utilisateurs ADD COLUMN is_admin INTEGER DEFAULT 0"); } catch (SQLException e) {}
|
||||
stmt.execute("INSERT OR IGNORE INTO utilisateurs(identifiant, mot_de_passe, is_admin) VALUES('admin', 'admin', 1)");
|
||||
|
||||
} catch (SQLException e) {
|
||||
System.out.println("Erreur lors de l'initialisation de la base de données principale : " + e.getMessage());
|
||||
}
|
||||
try (Statement stmtDiff = connDifficulte.createStatement()) {
|
||||
@@ -88,6 +91,14 @@ public class GestionnaireBDD {
|
||||
return -1;
|
||||
}
|
||||
|
||||
public boolean estAdmin(int userId) {
|
||||
try (PreparedStatement p = conn.prepareStatement("SELECT is_admin FROM utilisateurs WHERE id = ?")) {
|
||||
p.setInt(1, userId);
|
||||
ResultSet rs = p.executeQuery();
|
||||
return rs.next() && rs.getInt("is_admin") == 1;
|
||||
} catch (SQLException e) { return false; }
|
||||
}
|
||||
|
||||
public boolean creerCompte(String identifiant, String motDePasse) {
|
||||
String checkSql = "SELECT id FROM utilisateurs WHERE identifiant = ?";
|
||||
try (PreparedStatement checkPstmt = conn.prepareStatement(checkSql)) {
|
||||
|
||||
Reference in New Issue
Block a user