aboutsummaryrefslogtreecommitdiff
path: root/src/org
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2015-04-26 20:07:58 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2015-04-26 20:07:58 +1200
commit6919dc98ea4d546aea56e815c22fecc3a6c164c8 (patch)
treee05c4aed4922d3fdaed4dd51bce5938c0002f814 /src/org
parentb2cbb5698ee7eea9abd811a6cc653b624b09e7d9 (diff)
downloadtrackermap-server-6919dc98ea4d546aea56e815c22fecc3a6c164c8.tar.gz
trackermap-server-6919dc98ea4d546aea56e815c22fecc3a6c164c8.tar.bz2
trackermap-server-6919dc98ea4d546aea56e815c22fecc3a6c164c8.zip
Change user name to email
Diffstat (limited to 'src/org')
-rw-r--r--src/org/traccar/database/DataManager.java14
-rw-r--r--src/org/traccar/http/MainServlet.java2
2 files changed, 8 insertions, 8 deletions
diff --git a/src/org/traccar/database/DataManager.java b/src/org/traccar/database/DataManager.java
index 5e12dc865..4b8f4d5e8 100644
--- a/src/org/traccar/database/DataManager.java
+++ b/src/org/traccar/database/DataManager.java
@@ -239,7 +239,7 @@ public class DataManager {
statement.execute(
"CREATE TABLE user (" +
"id INT PRIMARY KEY AUTO_INCREMENT," +
- "name VARCHAR(1024) NOT NULL UNIQUE," +
+ "email VARCHAR(1024) NOT NULL UNIQUE," +
"password VARCHAR(1024) NOT NULL," +
"salt VARCHAR(1024) NOT NULL," +
"readonly BOOLEAN DEFAULT false NOT NULL," +
@@ -322,15 +322,15 @@ public class DataManager {
}
}
- public long login(String name, String password) throws SQLException {
+ public long login(String email, String password) throws SQLException {
Connection connection = dataSource.getConnection();
try {
PreparedStatement statement = connection.prepareStatement(
- "SELECT id FROM user WHERE name = ? AND " +
+ "SELECT id FROM user WHERE email = ? AND " +
"password = CAST(HASH('SHA256', STRINGTOUTF8(?), 1000) AS VARCHAR);");
try {
- statement.setString(1, name);
+ statement.setString(1, email);
statement.setString(2, password);
ResultSet result = statement.executeQuery();
@@ -344,15 +344,15 @@ public class DataManager {
}
}
- public void addUser(String name, String password, boolean admin) throws SQLException {
+ public void addUser(String email, String password, boolean admin) throws SQLException {
Connection connection = dataSource.getConnection();
try {
PreparedStatement statement = connection.prepareStatement(
- "INSERT INTO user (name, password, salt, admin) " +
+ "INSERT INTO user (email, password, salt, admin) " +
"VALUES (?, CAST(HASH('SHA256', STRINGTOUTF8(?), 1000) AS VARCHAR), '', ?);");
try {
- statement.setString(1, name);
+ statement.setString(1, email);
statement.setString(2, password);
statement.setBoolean(3, admin);
diff --git a/src/org/traccar/http/MainServlet.java b/src/org/traccar/http/MainServlet.java
index 655b47312..65a1bf624 100644
--- a/src/org/traccar/http/MainServlet.java
+++ b/src/org/traccar/http/MainServlet.java
@@ -240,7 +240,7 @@ public class MainServlet extends HttpServlet {
private void login(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
try {
req.getSession().setAttribute(USER_ID,
- Context.getDataManager().login(req.getParameter("name"), req.getParameter("password")));
+ Context.getDataManager().login(req.getParameter("email"), req.getParameter("password")));
resp.getWriter().println("{ success: true }");
} catch (SQLException e) {
throw new ServletException(e);