Fix the LDAP user log in by setting user_uuid SESSION and account for the user unique global option.
This commit is contained in:
parent
e3170d3c31
commit
a0e17a8bad
|
|
@ -118,13 +118,36 @@ require_once "resources/require.php";
|
||||||
if (strlen($_SESSION['username']) > 0) {
|
if (strlen($_SESSION['username']) > 0) {
|
||||||
$sql = "select * from v_users ";
|
$sql = "select * from v_users ";
|
||||||
$sql .= "where username=:username ";
|
$sql .= "where username=:username ";
|
||||||
|
if ($_SESSION["user"]["unique"]["text"] == "global") {
|
||||||
|
//unique username - global (example: email address)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
//unique username - per domain
|
||||||
$sql .= "and domain_uuid=:domain_uuid ";
|
$sql .= "and domain_uuid=:domain_uuid ";
|
||||||
|
}
|
||||||
$prep_statement = $db->prepare(check_sql($sql));
|
$prep_statement = $db->prepare(check_sql($sql));
|
||||||
|
if ($_SESSION["user"]["unique"]["text"] != "global") {
|
||||||
$prep_statement->bindParam(':domain_uuid', $domain_uuid);
|
$prep_statement->bindParam(':domain_uuid', $domain_uuid);
|
||||||
|
}
|
||||||
$prep_statement->bindParam(':username', $username);
|
$prep_statement->bindParam(':username', $username);
|
||||||
$prep_statement->execute();
|
$prep_statement->execute();
|
||||||
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||||
if (count($result) == 0) {
|
if (count($result) > 0) {
|
||||||
|
foreach ($result as &$row) {
|
||||||
|
//get the domain uuid
|
||||||
|
$domain_uuid = $row["domain_uuid"];
|
||||||
|
$user_uuid = $row["user_uuid"];
|
||||||
|
//set the domain session variables
|
||||||
|
$_SESSION["domain_uuid"] = $domain_uuid;
|
||||||
|
$domain_name = $_SESSION['domains'][$domain_uuid]['domain_name'];
|
||||||
|
$_SESSION["domain_name"] = $domain_name;
|
||||||
|
//set the setting arrays
|
||||||
|
$domain = new domains();
|
||||||
|
$domain->db = $db;
|
||||||
|
$domain->set();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
//salt used with the password to create a one way hash
|
//salt used with the password to create a one way hash
|
||||||
$salt = generate_password('32', '4');
|
$salt = generate_password('32', '4');
|
||||||
$password = generate_password('32', '4');
|
$password = generate_password('32', '4');
|
||||||
|
|
@ -133,6 +156,9 @@ require_once "resources/require.php";
|
||||||
$user_uuid = uuid();
|
$user_uuid = uuid();
|
||||||
$contact_uuid = uuid();
|
$contact_uuid = uuid();
|
||||||
|
|
||||||
|
//set the user_id
|
||||||
|
$_SESSION["user_uuid"] = $user_uuid;
|
||||||
|
|
||||||
//add the user
|
//add the user
|
||||||
$sql = "insert into v_users ";
|
$sql = "insert into v_users ";
|
||||||
$sql .= "(";
|
$sql .= "(";
|
||||||
|
|
@ -222,7 +248,8 @@ require_once "resources/require.php";
|
||||||
$domain_uuid = $row["domain_uuid"];
|
$domain_uuid = $row["domain_uuid"];
|
||||||
//set the domain session variables
|
//set the domain session variables
|
||||||
$_SESSION["domain_uuid"] = $domain_uuid;
|
$_SESSION["domain_uuid"] = $domain_uuid;
|
||||||
$_SESSION["domain_name"] = $_SESSION['domains'][$domain_uuid]['domain_name'];
|
$domain_name = $_SESSION['domains'][$domain_uuid]['domain_name'];
|
||||||
|
$_SESSION["domain_name"] = $domain_name;
|
||||||
//set the setting arrays
|
//set the setting arrays
|
||||||
$domain = new domains();
|
$domain = new domains();
|
||||||
$domain->db = $db;
|
$domain->db = $db;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue