aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/database
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/traccar/database')
-rw-r--r--src/org/traccar/database/DataManager.java17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/org/traccar/database/DataManager.java b/src/org/traccar/database/DataManager.java
index 54f1cdc3a..db863e8f4 100644
--- a/src/org/traccar/database/DataManager.java
+++ b/src/org/traccar/database/DataManager.java
@@ -221,10 +221,16 @@ public class DataManager {
.executeQuerySingle(new User());
}
+ public Collection<User> getUsers() throws SQLException {
+ return QueryBuilder.create(dataSource,
+ "SELECT * FROM user;")
+ .executeQuery(new User());
+ }
+
public void addUser(User user) throws SQLException {
user.setId(QueryBuilder.create(dataSource,
- "INSERT INTO user (name, email, password, salt, admin) " +
- "VALUES (:name, :email, CAST(HASH('SHA256', STRINGTOUTF8(:password), 1000) AS VARCHAR), '', :admin);")
+ "INSERT INTO user (name, email, password, admin) " +
+ "VALUES (:name, :email, CAST(HASH('SHA256', STRINGTOUTF8(:password), 1000) AS VARCHAR), :admin);")
.setObject(user)
.executeUpdate());
}
@@ -236,6 +242,13 @@ public class DataManager {
.setObject(user)
.executeUpdate();
}
+
+ public void removeUser(User user) throws SQLException {
+ QueryBuilder.create(dataSource,
+ "DELETE FROM user WHERE id = :id;")
+ .setObject(user)
+ .executeUpdate();
+ }
public Collection<Permission> getPermissions() throws SQLException {
return QueryBuilder.create(dataSource,