Skip to content

Commit

Permalink
Fix: Could not add picture see #88 (#89)
Browse files Browse the repository at this point in the history
  • Loading branch information
invisiblemarcel authored Apr 19, 2024
1 parent 17afcc9 commit 2c83a54
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
7 changes: 5 additions & 2 deletions inc/provider.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -868,8 +868,10 @@ public function getResourceOwnerDetailsUrl($access_token = null) {

$url = $fields['url_resource_owner_details'];

$url = str_replace("<access_token>", $access_token, $url);
$url = str_replace("<appsecret_proof>", hash_hmac('sha256', $access_token, $this->getClientSecret()), $url);
if (!IS_NULL($access_token)) {
$url = str_replace("<access_token>", $access_token, $url);
$url = str_replace("<appsecret_proof>", hash_hmac('sha256', $access_token, $this->getClientSecret()), $url);
}

return $url;
}
Expand Down Expand Up @@ -1257,6 +1259,7 @@ public function findUser() {
'realname' => $realname,
'firstname' => $firstname,
//'picture' => $resource_array['picture'] ?? '',
'picture' => $resource_array['picture'],
'api_token' => $tokenAPI,
'personal_token' => $tokenPersonnel,
'is_active' => 1
Expand Down
8 changes: 6 additions & 2 deletions inc/toolbox.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ static function getPictureUrl($path) {
return $CFG_GLPI['root_doc'] . '/plugins/singlesignon/front/picture.send.php?path=' . $path;
}

static public function savePicture($src, $uniq_prefix = null) {
static public function savePicture($src, $uniq_prefix = "") {

if (function_exists('Document::isImage') && !Document::isImage($src)) {
return false;
Expand All @@ -131,7 +131,11 @@ static public function savePicture($src, $uniq_prefix = null) {
. '/' . $filename . ($i > 0 ? '_' . $i : '') . '.' . $ext;
$i++;
} while (file_exists($dest));

// If the base directory does not exists, create it
if (!is_dir($basePath) && !mkdir($basePath)) {
return false;
}
// If the sub directory does not exists, create the sub directory
if (!is_dir($basePath . '/' . $subdirectory) && !mkdir($basePath . '/' . $subdirectory)) {
return false;
}
Expand Down

0 comments on commit 2c83a54

Please sign in to comment.