Update database.php
This commit is contained in:
parent
d349c21e68
commit
e1d5b87843
|
|
@ -30,17 +30,20 @@ class plugin_database {
|
||||||
$user_authorized = false;
|
$user_authorized = false;
|
||||||
|
|
||||||
//check the username and password if they don't match then redirect to the login
|
//check the username and password if they don't match then redirect to the login
|
||||||
$sql = "select * from v_users where ";
|
$sql = "select * from v_users ";
|
||||||
if (strlen($this->key) > 30) {
|
if (strlen($this->key) > 30) {
|
||||||
$sql .= "api_key = :key ";
|
$sql .= "where api_key = :key ";
|
||||||
$parameters['api_key'] = $this->key;
|
$parameters['api_key'] = $this->key;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$sql .= "lower(username) = lower(:username) ";
|
$sql .= "where lower(username) = lower(:username) ";
|
||||||
$parameters['username'] = $this->username;
|
$parameters['username'] = $this->username;
|
||||||
}
|
}
|
||||||
if ($_SESSION["users"]["unique"]["text"] != "global") {
|
if ($_SESSION["users"]["unique"]["text"] == "global") {
|
||||||
//unique username per domain (not globally unique across system - example: email address)
|
//unique username - global (example: email address)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
//unique username - per domain
|
||||||
$sql .= "and domain_uuid = :domain_uuid ";
|
$sql .= "and domain_uuid = :domain_uuid ";
|
||||||
$parameters['domain_uuid'] = $this->domain_uuid;
|
$parameters['domain_uuid'] = $this->domain_uuid;
|
||||||
}
|
}
|
||||||
|
|
@ -81,6 +84,9 @@ class plugin_database {
|
||||||
else if (strlen($this->key) > 30 && $this->key == $row["api_key"]) {
|
else if (strlen($this->key) > 30 && $this->key == $row["api_key"]) {
|
||||||
$user_authorized = true;
|
$user_authorized = true;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
$user_authorized = false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
unset($result);
|
unset($result);
|
||||||
|
|
@ -96,10 +102,14 @@ class plugin_database {
|
||||||
$result["domain_uuid"] = $this->domain_uuid;
|
$result["domain_uuid"] = $this->domain_uuid;
|
||||||
$result["contact_uuid"] = $this->contact_uuid;
|
$result["contact_uuid"] = $this->contact_uuid;
|
||||||
$result["sql"] = $sql;
|
$result["sql"] = $sql;
|
||||||
$result["authorized"] = $user_authorized ? 'true' : 'false';
|
if ($user_authorized) {
|
||||||
|
$result["authorized"] = "true";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$result["authorized"] = "false";
|
||||||
|
}
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue