]> git.mxchange.org Git - friendica.git/commitdiff
expand permission check to remote array
authorDean Townsley <dean@townsley.com>
Sat, 8 Jun 2019 15:11:02 +0000 (10:11 -0500)
committerDean Townsley <dean@townsley.com>
Mon, 10 Jun 2019 02:06:42 +0000 (21:06 -0500)
This check was preventing multiple private images from different
users on the same server from loading on the same page.
It was only checking for permission for the single id returned by the
remote_user() function rather than the multiple possible autheniticated
id's stored in the remote arry session variable.

src/Util/Security.php

index d1e668e0d8ce80a46ec101630d5a1fb4a88db9ce..0680bc08c176235fb1d288214a127eb225dcc875 100644 (file)
@@ -120,9 +120,21 @@ class Security extends BaseObject
                         */
 
                        if (!$remote_verified) {
-                               if (DBA::exists('contact', ['id' => $remote_user, 'uid' => $owner_id, 'blocked' => false])) {
+                               $cid = 0;
+
+                               if (!empty($_SESSION['remote'])) {
+                                       foreach ($_SESSION['remote'] as $visitor) {
+                                               Logger::log("this remote array entry is".$visitor);
+                                               if ($visitor['uid'] == $owner_id) {
+                                                       $cid = $visitor['cid'];
+                                                       break;
+                                               }
+                                       }
+                               }
+
+                               if ($cid && DBA::exists('contact', ['id' => $cid, 'uid' => $owner_id, 'blocked' => false])) {
                                        $remote_verified = true;
-                                       $groups = Group::getIdsByContactId($remote_user);
+                                       $groups = Group::getIdsByContactId($cid);
                                }
                        }
 
@@ -140,9 +152,9 @@ class Security extends BaseObject
                                          AND ( allow_cid REGEXP '<%d>' OR allow_gid REGEXP '%s' OR ( allow_cid = '' AND allow_gid = '') )
                                          )
                                        ",
-                                       intval($remote_user),
+                                       intval($cid),
                                        DBA::escape($gs),
-                                       intval($remote_user),
+                                       intval($cid),
                                        DBA::escape($gs)
                                );
                        }