Просмотр исходного кода

#1578 OAuth: incorrect usage of user_id variable

Alex Trofimov 8 лет назад
Родитель
Сommit
9147e0cd46
1 измененных файлов с 11 добавлено и 3 удалено
  1. 11 3
      modules/boonex/oauth2/classes/BxOAuthAPI.php

+ 11 - 3
modules/boonex/oauth2/classes/BxOAuthAPI.php

@@ -101,8 +101,11 @@ class BxOAuthAPI extends BxDol
 
         if (!($oProfile = $this->_getProfileWithAccessChecking($iProfileId)))
             return;
-        
-        $this->output($this->_prepareProfileArray($oProfile, !isAdmin($aToken['user_id'])));
+
+        if (!($oProfile = BxDolProfile::getInstance($aToken['user_id'])))
+            return;
+
+        $this->output($this->_prepareProfileArray($oProfile, !isAdmin($oProfile->getAccountId())));
     }
 
     /**
@@ -228,7 +231,12 @@ class BxOAuthAPI extends BxDol
      */
     function service($aToken) 
     {
-        bx_login($aToken['user_id'], false, false);
+        if (!($oProfile = BxDolProfile::getInstance($aToken['user_id']))) {
+            $this->errorOutput('404', 'not_found', 'Profile was not found');
+            return;
+        }
+        
+        bx_login($oProfile->getAccountId(), false, false);
 
         $sModule = bx_get('module');
         $sMethod = bx_get('method');