update assignUser function

dev
Oana Ursuleasa 2025-01-27 16:17:56 +02:00
rodzic 27838db415
commit c7eb622740
2 zmienionych plików z 7 dodań i 5 usunięć

Wyświetl plik

@ -3,6 +3,8 @@ define("NC_SERVER", "localhost"); // https://server.domain (without "https://" a
define("NC_HOST", "host"); //server.domain
define("NC_USER", "deckbot");
define("NC_PASSWORD", "****"); // if your Nextcloud instance uses Two-Factor-Authentication, use generated token here instead of password.
define("NC_ADMIN_USER", "admin"); // to access the nextcloud users list you need an admin
define("NC_ADMIN_PASSWORD", "admin");
define("MAIL_SERVER", "localhost"); // server.domain
define("MAIL_SERVER_FLAGS", "/novalidate-cert"); // flags needed to connect to server. Refer to https://www.php.net/manual/en/function.imap-open.php for a list of valid flags.
define("MAIL_SERVER_PORT", "143");

Wyświetl plik

@ -21,7 +21,7 @@ class DeckClass {
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => $request,
CURLOPT_HTTPHEADER => array(
'Authorization: Basic ' . base64_encode(NC_USER . ':' . NC_PASSWORD),
'Authorization: Basic ' . base64_encode(NC_ADMIN_USER . ':' . NC_ADMIN_PASSWORD),
'OCS-APIRequest: true',
),
));
@ -33,7 +33,7 @@ class DeckClass {
'Accept: application/json',
'OCS-APIRequest: true',
'Content-Type: application/json',
'Authorization: Basic ' . base64_encode(NC_USER . ':' . NC_PASSWORD),
'Authorization: Basic ' . base64_encode(NC_ADMIN_USER . ':' . NC_ADMIN_PASSWORD),
)
));
}
@ -146,10 +146,10 @@ class DeckClass {
//Assign a user to the card
public function assignUser($card, $mailUser)
{
$adminUser = urlencode(NC_USER);
$adminPassword = urlencode(NC_PASSWORD);
$adminUser = urlencode(NC_ADMIN_USER);
$adminPassword = urlencode(NC_ADMIN_PASSWORD);
$url = "http://{$adminUser}:{$adminPassword}@" . NC_HOST;
$url = "https://{$adminUser}:{$adminPassword}@" . NC_HOST;
$allUsers= $this->apiCall("GET",$url."/ocs/v1.php/cloud/users", null, false, true); //nextcloud user list
foreach ($allUsers->data->users->element as $userId) {