mirror of
https://github.com/misterunknown/ifm.git
synced 2025-08-09 17:46:31 +02:00
LDAP filter fix, disable reload on submit login form.
LDAP Template new format: auth;server_url;baseDN;userUID;user_filter LDAP Example ldap;ldap[s]://ldap.example.com:389[636];cn=users,cn=accounts,dc=example,dc=com;uid;(objectClass=*)
This commit is contained in:
14
src/ifm.js
14
src/ifm.js
@@ -1907,9 +1907,9 @@ function IFM(params) {
|
|||||||
success: function(d) {
|
success: function(d) {
|
||||||
if (d.status == "ERROR") {
|
if (d.status == "ERROR") {
|
||||||
self.showModal(Mustache.render(self.templates.login, {i18n: self.i18n}), {large: true});
|
self.showModal(Mustache.render(self.templates.login, {i18n: self.i18n}), {large: true});
|
||||||
|
|
||||||
var form = document.forms.loginForm;
|
var form = document.forms.loginForm;
|
||||||
form.addEventListener('click', function(e) {
|
form.addEventListener('click', function(e) {
|
||||||
|
e.preventDefault();
|
||||||
if (e.target.id == "buttonLogin") {
|
if (e.target.id == "buttonLogin") {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: self.api,
|
url: self.api,
|
||||||
@@ -1925,7 +1925,10 @@ function IFM(params) {
|
|||||||
self.initApplication();
|
self.initApplication();
|
||||||
},
|
},
|
||||||
error: function(e) {
|
error: function(e) {
|
||||||
self.showMessage("Authentication failed", "e");
|
var errorlogin = document.getElementsByClassName('alert')[0];
|
||||||
|
errorlogin.classList.remove("d-none");
|
||||||
|
errorlogin.innerHTML = "Authentication failed"
|
||||||
|
//self.showMessage("Authentication failed", "e");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -1933,10 +1936,11 @@ function IFM(params) {
|
|||||||
} else {
|
} else {
|
||||||
self.initApplication();
|
self.initApplication();
|
||||||
}
|
}
|
||||||
},
|
|
||||||
error: function(resp) {
|
|
||||||
throw new Error("Not authenticated");
|
|
||||||
}
|
}
|
||||||
|
// },
|
||||||
|
// error: function(resp) {
|
||||||
|
// throw new Error("Not authenticated");
|
||||||
|
// }
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
13
src/main.php
13
src/main.php
@@ -1017,15 +1017,16 @@ f00bar;
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "ldap":
|
case "ldap":
|
||||||
$authenticated = false;
|
$authenticated = false;
|
||||||
$ldapopts = explode(";", $srcopt);
|
$ldapopts = explode(";", $srcopt);
|
||||||
if (count($ldapopts) === 3) {
|
if (count($ldapopts) === 4) {
|
||||||
list($ldap_server, $rootdn, $ufilter) = explode(";", $srcopt);
|
list($ldap_server, $basedn, $uuid, $ufilter) = explode(";", $srcopt);
|
||||||
} else {
|
} else {
|
||||||
list($ldap_server, $rootdn) = explode(";", $srcopt);
|
list($ldap_server, $basedn) = explode(";", $srcopt);
|
||||||
$ufilter = false;
|
$ufilter = false;
|
||||||
|
$uuid = "uid";
|
||||||
}
|
}
|
||||||
$u = "uid=" . $user . "," . $rootdn;
|
$u = $uuid . "=" . $user . "," . $basedn;
|
||||||
if (!$ds = ldap_connect($ldap_server)) {
|
if (!$ds = ldap_connect($ldap_server)) {
|
||||||
trigger_error("Could not reach the ldap server.", E_USER_ERROR);
|
trigger_error("Could not reach the ldap server.", E_USER_ERROR);
|
||||||
return false;
|
return false;
|
||||||
@@ -1035,7 +1036,7 @@ f00bar;
|
|||||||
$ldbind = @ldap_bind($ds, $u, $pass);
|
$ldbind = @ldap_bind($ds, $u, $pass);
|
||||||
if ($ldbind) {
|
if ($ldbind) {
|
||||||
if ($ufilter) {
|
if ($ufilter) {
|
||||||
if (ldap_count_entries($ds, ldap_search($ds, $rootdn, $ufilter)) > 0) {
|
if (ldap_count_entries($ds, ldap_search($ds, $u, $ufilter)) > 0) {
|
||||||
$authenticated = true;
|
$authenticated = true;
|
||||||
} else {
|
} else {
|
||||||
trigger_error("User not allowed.", E_USER_ERROR);
|
trigger_error("User not allowed.", E_USER_ERROR);
|
||||||
|
Reference in New Issue
Block a user