Browse Source

#739 OAuth2: choose profile dialog bug

Alex Trofimov 9 years ago
parent
commit
c7bf9c7e4e

+ 2 - 2
modules/boonex/oauth2/classes/BxOAuthDb.php

@@ -101,10 +101,10 @@ class BxOAuthDb extends BxDolModuleDb
         return $this->query("DELETE FROM `bx_oauth_clients` WHERE " . $this->arrayToSQL($aParams, ' AND '));
     }
 
-    function getSavedProfile($aProfiles)
+    function getSavedProfile($sClientId, $aProfiles)
     {
         $aIds = array_keys($aProfiles);
-        return $this->getOne("SELECT `user_id` FROM `bx_oauth_refresh_tokens` WHERE `user_id` IN (" . $this->implode_escape($aIds) . ") LIMIT 1");
+        return $this->getOne("SELECT `user_id` FROM `bx_oauth_refresh_tokens` WHERE `client_id` = ? AND `user_id` IN (" . $this->implode_escape($aIds) . ") LIMIT 1", array($sClientId));
     }
 
 }

+ 1 - 1
modules/boonex/oauth2/classes/BxOAuthModule.php

@@ -167,7 +167,7 @@ class BxOAuthModule extends BxDolModule
             $_POST['profile_id'] = $aProfile['id'];
         }
 
-        if (!($iProfileId = $this->_oDb->getSavedProfile($aProfiles)) && empty($_POST)) {
+        if (!($iProfileId = $this->_oDb->getSavedProfile(bx_get('client_id'), $aProfiles)) && empty($_POST)) {
             $oPage = BxDolPage::getObjectInstanceByURI('oauth-authorization');
             $this->_oTemplate->getPage(false, $oPage->getCode());
             return;