aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/database/DataManager.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2015-06-06 18:40:54 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2015-06-06 18:40:54 +1200
commit40107a7886412c4582ea9a9ee946f454e28a1178 (patch)
treebc6c3f7b6eac4a27e6b8403efbb258be46ddb787 /src/org/traccar/database/DataManager.java
parent926873438a66abcbaa204884970663e70b6882f8 (diff)
downloadtraccar-server-40107a7886412c4582ea9a9ee946f454e28a1178.tar.gz
traccar-server-40107a7886412c4582ea9a9ee946f454e28a1178.tar.bz2
traccar-server-40107a7886412c4582ea9a9ee946f454e28a1178.zip
Add users API servlet
Diffstat (limited to 'src/org/traccar/database/DataManager.java')
-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,