aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/database/DataManager.java
diff options
context:
space:
mode:
authorShinryuken <watertext@hotmail.it>2017-11-19 11:22:31 +0100
committerGitHub <noreply@github.com>2017-11-19 11:22:31 +0100
commita5b273f8f8afd1a67613517c6487642601070456 (patch)
treebabc63f5d50977fc91b3946b1da2e86ec74c51a5 /src/org/traccar/database/DataManager.java
parentc7928ef4a722cb40e9911c8e76e308fc48c85567 (diff)
parentfb9cbb2b74dc0060bd0dc5d0b3bfeb958ed6f3b5 (diff)
downloadtrackermap-server-a5b273f8f8afd1a67613517c6487642601070456.tar.gz
trackermap-server-a5b273f8f8afd1a67613517c6487642601070456.tar.bz2
trackermap-server-a5b273f8f8afd1a67613517c6487642601070456.zip
Merge branch 'master' into payload-as-form-param
Diffstat (limited to 'src/org/traccar/database/DataManager.java')
-rw-r--r--src/org/traccar/database/DataManager.java20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/org/traccar/database/DataManager.java b/src/org/traccar/database/DataManager.java
index e88ff7f0d..abc424ff9 100644
--- a/src/org/traccar/database/DataManager.java
+++ b/src/org/traccar/database/DataManager.java
@@ -40,6 +40,7 @@ import liquibase.resource.FileSystemResourceAccessor;
import liquibase.resource.ResourceAccessor;
import org.traccar.Config;
+import org.traccar.Context;
import org.traccar.helper.Log;
import org.traccar.model.Attribute;
import org.traccar.model.Device;
@@ -75,9 +76,13 @@ public class DataManager {
private boolean generateQueries;
+ private boolean forceLdap;
+
public DataManager(Config config) throws Exception {
this.config = config;
+ forceLdap = config.getBoolean("ldap.force");
+
initDatabase();
initDatabaseSchema();
}
@@ -300,11 +305,20 @@ public class DataManager {
User user = QueryBuilder.create(dataSource, getQuery("database.loginUser"))
.setString("email", email.trim())
.executeQuerySingle(User.class);
- if (user != null && user.isPasswordValid(password)) {
- return user;
+ LdapProvider ldapProvider = Context.getLdapProvider();
+ if (user != null) {
+ if (ldapProvider != null && ldapProvider.login(user.getLogin(), password)
+ || !forceLdap && user.isPasswordValid(password)) {
+ return user;
+ }
} else {
- return null;
+ if (ldapProvider != null && ldapProvider.login(email, password)) {
+ user = ldapProvider.getUser(email);
+ Context.getUsersManager().addItem(user);
+ return user;
+ }
}
+ return null;
}
public void updateDeviceStatus(Device device) throws SQLException {