Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Commit

Permalink
[ConfService] Use a dedicated UserAlertException to send back OAuth m…
Browse files Browse the repository at this point in the history
…essage and avoid removing temporary failing workspace from the list. Use it in access.dropbox driver.
  • Loading branch information
cdujeu committed Dec 8, 2015
1 parent 5a9dd95 commit f057f14
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
26 changes: 26 additions & 0 deletions core/src/core/classes/class.AJXP_UserAlertException.php
@@ -0,0 +1,26 @@
<?php
/*
* Copyright 2007-2015 Abstrium <contact (at) pydio.com>
* This file is part of Pydio.
*
* Pydio is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Pydio is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Pydio. If not, see <http://www.gnu.org/licenses/>.
*
* The latest code can be found at <http://pyd.io/>.
*/

defined('AJXP_EXEC') or die('Access not allowed');

class AJXP_UserAlertException extends AJXP_Exception{

}
4 changes: 3 additions & 1 deletion core/src/core/classes/class.ConfService.php
Expand Up @@ -1552,7 +1552,9 @@ private function loadRepositoryDriverInst(&$repository = null)
} catch (Exception $e) {
if(!$rest){
// Remove repositories from the lists
$this->removeRepositoryFromCache($repository->getId());
if(!is_a($e, "AJXP_UserAlertException")){
$this->removeRepositoryFromCache($repository->getId());
}
if (isSet($_SESSION["PREVIOUS_REPO_ID"]) && $_SESSION["PREVIOUS_REPO_ID"] !=$repository->getId()) {
$this->switchRootDir($_SESSION["PREVIOUS_REPO_ID"]);
} else {
Expand Down
4 changes: 2 additions & 2 deletions core/src/plugins/access.dropbox/class.dropboxAccessDriver.php
Expand Up @@ -83,14 +83,14 @@ public function initRepository()
//echo "Step 2: You must now redirect the user to:\n";
$_SESSION['DROPBOX_NEGOCIATION_STATE'] = 2;
$_SESSION['oauth_tokens'] = $tokens;
throw new Exception("Please go to <a style=\"text-decoration:underline;\" target=\"_blank\" href=\"".$oauth->getAuthorizeUrl()."\">".$oauth->getAuthorizeUrl()."</a> to authorize the access to your dropbox. Then try again to switch to this workspace.");
throw new AJXP_UserAlertException("Please go to <a style=\"text-decoration:underline;\" target=\"_blank\" href=\"".$oauth->getAuthorizeUrl()."\">".$oauth->getAuthorizeUrl()."</a> to authorize the access to your dropbox. Then try again to switch to this workspace.");

case 2 :
$oauth->setToken($_SESSION['oauth_tokens']);
try{
$tokens = $oauth->getAccessToken();
}catch(Exception $oauthEx){
throw new Exception($oauthEx->getMessage() . ". Please go to <a style=\"text-decoration:underline;\" target=\"_blank\" href=\"".$oauth->getAuthorizeUrl()."\">".$oauth->getAuthorizeUrl()."</a> to authorize the access to your dropbox. Then try again to switch to this workspace.");
throw new AJXP_UserAlertException($oauthEx->getMessage() . ". Please go to <a style=\"text-decoration:underline;\" target=\"_blank\" href=\"".$oauth->getAuthorizeUrl()."\">".$oauth->getAuthorizeUrl()."</a> to authorize the access to your dropbox. Then try again to switch to this workspace.");
}
$_SESSION['DROPBOX_NEGOCIATION_STATE'] = 3;
$_SESSION['OAUTH_DROPBOX_TOKENS'] = $tokens;
Expand Down

0 comments on commit f057f14

Please sign in to comment.