From 2a277bbc038cbe0f6a067f42023f193e96650801 Mon Sep 17 00:00:00 2001 From: Bob Trahan Date: Fri, 21 Feb 2014 13:04:23 -0800 Subject: [PATCH] Hide upload JS stuff if user isn't logged in Summary: ...cuz it won't work. I think adding a "login to upload" has no real value as this is a pretty unexpected / power user feature anyway. Fixes T4354. Test Plan: tried to upload as a logged out user to Phabricator home. my browser just loaded the file as expected. Reviewers: epriestley Reviewed By: epriestley CC: Korvin, epriestley, aran Maniphest Tasks: T4354 Differential Revision: https://secure.phabricator.com/D8298 --- .../files/controller/PhabricatorFileListController.php | 3 ++- .../files/controller/PhabricatorFileUploadController.php | 1 + .../files/view/PhabricatorGlobalUploadTargetView.php | 5 +++++ .../home/controller/PhabricatorHomeMainController.php | 4 +++- 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/applications/files/controller/PhabricatorFileListController.php b/src/applications/files/controller/PhabricatorFileListController.php index 07089758e2..787df9f102 100644 --- a/src/applications/files/controller/PhabricatorFileListController.php +++ b/src/applications/files/controller/PhabricatorFileListController.php @@ -78,7 +78,8 @@ final class PhabricatorFileListController extends PhabricatorFileController $list_view->addItem($item); } - $list_view->appendChild(new PhabricatorGlobalUploadTargetView()); + $list_view->appendChild(id(new PhabricatorGlobalUploadTargetView()) + ->setUser($user)); return $list_view; } diff --git a/src/applications/files/controller/PhabricatorFileUploadController.php b/src/applications/files/controller/PhabricatorFileUploadController.php index 4f3d19d9e1..69dd3541a7 100644 --- a/src/applications/files/controller/PhabricatorFileUploadController.php +++ b/src/applications/files/controller/PhabricatorFileUploadController.php @@ -65,6 +65,7 @@ final class PhabricatorFileUploadController extends PhabricatorFileController { $title = pht('Upload File'); $global_upload = id(new PhabricatorGlobalUploadTargetView()) + ->setUser($user) ->setShowIfSupportedID($support_id); $form_box = id(new PHUIObjectBoxView()) diff --git a/src/applications/files/view/PhabricatorGlobalUploadTargetView.php b/src/applications/files/view/PhabricatorGlobalUploadTargetView.php index 15f6adba83..f5c7858a98 100644 --- a/src/applications/files/view/PhabricatorGlobalUploadTargetView.php +++ b/src/applications/files/view/PhabricatorGlobalUploadTargetView.php @@ -14,6 +14,11 @@ final class PhabricatorGlobalUploadTargetView extends AphrontView { } public function render() { + $viewer = $this->getUser(); + if (!$viewer->isLoggedIn()) { + return null; + } + $instructions_id = celerity_generate_unique_node_id(); require_celerity_resource('global-drag-and-drop-css'); diff --git a/src/applications/home/controller/PhabricatorHomeMainController.php b/src/applications/home/controller/PhabricatorHomeMainController.php index b4cb8a0e3b..86c7396f43 100644 --- a/src/applications/home/controller/PhabricatorHomeMainController.php +++ b/src/applications/home/controller/PhabricatorHomeMainController.php @@ -75,8 +75,10 @@ final class PhabricatorHomeMainController $this->minipanels, ); + $user = $this->getRequest()->getUser(); $nav->appendChild($content); - $nav->appendChild(new PhabricatorGlobalUploadTargetView()); + $nav->appendChild(id(new PhabricatorGlobalUploadTargetView()) + ->setUser($user)); return $this->buildApplicationPage( $nav,