diff options
-rw-r--r-- | src/org/traccar/database/DataManager.java | 14 | ||||
-rw-r--r-- | src/org/traccar/http/MainServlet.java | 2 | ||||
-rw-r--r-- | web/Login.js | 4 | ||||
-rw-r--r-- | web/Strings.js | 4 |
4 files changed, 12 insertions, 12 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); diff --git a/web/Login.js b/web/Login.js index bdae5723d..f31b2c728 100644 --- a/web/Login.js +++ b/web/Login.js @@ -27,8 +27,8 @@ Ext.define('LoginForm', { items: [{ allowBlank: false, - fieldLabel: Strings.login_user, - name: 'name' + fieldLabel: Strings.login_email, + name: 'email' }, { allowBlank: false, fieldLabel: Strings.login_password, diff --git a/web/Strings.js b/web/Strings.js index d853a8f00..fcf86ef65 100644 --- a/web/Strings.js +++ b/web/Strings.js @@ -18,11 +18,11 @@ Ext.define('Strings', { singleton: true, login_title: 'Login', - login_user: 'User', + login_email: 'Email', login_password: 'Password', login_register: 'Register', login_login: 'Login', - login_failed: 'Incorrect user name or password.', + login_failed: 'Incorrect email address or password.', device_title: 'Devices', device_name: 'Name', |