Prevent edge case PHP 8.1 warnings for domain_uuid and domain_name
This commit is contained in:
parent
32409f88b2
commit
cd91040eb5
|
|
@ -153,8 +153,8 @@ class plugin_database {
|
|||
//get the domain name
|
||||
$auth = new authentication;
|
||||
$auth->get_domain();
|
||||
$this->domain_uuid = $_SESSION['domain_uuid'];
|
||||
$this->domain_name = $_SESSION['domain_name'];
|
||||
$this->domain_uuid = $_SESSION['domain_uuid'] ?? null;
|
||||
$this->domain_name = $_SESSION['domain_name'] ?? null;
|
||||
$this->username = $_SESSION['username'] ?? null;
|
||||
|
||||
//debug information
|
||||
|
|
@ -195,12 +195,28 @@ class plugin_database {
|
|||
$row = $database->select($sql, $parameters, 'row');
|
||||
if (!empty($row) && is_array($row) && @sizeof($row) != 0) {
|
||||
|
||||
//set the domain details
|
||||
$this->domain_uuid = $_SESSION['domain_uuid'];
|
||||
$this->domain_name = $_SESSION['domain_name'];
|
||||
//validate the password
|
||||
$valid_password = false;
|
||||
if (isset($this->key) && strlen($this->key) > 30 && $this->key === $row["api_key"]) {
|
||||
$valid_password = true;
|
||||
}
|
||||
else if (substr($row["password"], 0, 1) === '$') {
|
||||
if (isset($this->password) && !empty($this->password)) {
|
||||
if (password_verify($this->password, $row["password"])) {
|
||||
$valid_password = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
//deprecated - compare the password provided by the user with the one in the database
|
||||
if (md5($row["salt"].$this->password) === $row["password"]) {
|
||||
$row["password"] = crypt($this->password, '$1$'.$password_salt.'$');
|
||||
$valid_password = true;
|
||||
}
|
||||
}
|
||||
|
||||
//get the domain uuid when users are unique globally
|
||||
if ($settings['users']['unique'] === "global" && $row["domain_uuid"] !== $this->domain_uuid) {
|
||||
//set the domain and user settings
|
||||
if ($valid_password) {
|
||||
//set the domain_uuid
|
||||
$this->domain_uuid = $row["domain_uuid"];
|
||||
$this->domain_name = $row["domain_name"];
|
||||
|
|
@ -209,7 +225,8 @@ class plugin_database {
|
|||
$_SESSION["domain_uuid"] = $this->domain_uuid;
|
||||
$_SESSION["domain_name"] = $this->domain_name;
|
||||
|
||||
//set the setting arrays
|
||||
//set the domain setting
|
||||
if ($settings['users']['unique'] === "global" && $row["domain_uuid"] !== $this->domain_uuid) {
|
||||
$domain = new domains();
|
||||
$domain->set();
|
||||
}
|
||||
|
|
@ -230,25 +247,6 @@ class plugin_database {
|
|||
$_SESSION["username"] = $row['username'];
|
||||
$_SESSION["user_email"] = $row['user_email'];
|
||||
$_SESSION["contact_uuid"] = $row["contact_uuid"];
|
||||
|
||||
//validate the password
|
||||
$valid_password = false;
|
||||
if (isset($this->key) && strlen($this->key) > 30 && $this->key === $row["api_key"]) {
|
||||
$valid_password = true;
|
||||
}
|
||||
else if (substr($row["password"], 0, 1) === '$') {
|
||||
if (isset($this->password) && !empty($this->password)) {
|
||||
if (password_verify($this->password, $row["password"])) {
|
||||
$valid_password = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
//deprecated - compare the password provided by the user with the one in the database
|
||||
if (md5($row["salt"].$this->password) === $row["password"]) {
|
||||
$row["password"] = crypt($this->password, '$1$'.$password_salt.'$');
|
||||
$valid_password = true;
|
||||
}
|
||||
}
|
||||
|
||||
//check to to see if the the password hash needs to be updated
|
||||
|
|
|
|||
Loading…
Reference in New Issue