diff --git a/src/applications/auth/controller/PhabricatorLoginController.php b/src/applications/auth/controller/PhabricatorLoginController.php index f4bb0ab57a..19b589934d 100644 --- a/src/applications/auth/controller/PhabricatorLoginController.php +++ b/src/applications/auth/controller/PhabricatorLoginController.php @@ -70,11 +70,15 @@ final class PhabricatorLoginController )); } - $next_uri_path = $this->getRequest()->getPath(); - if ($next_uri_path == '/login/') { - $next_uri = '/'; - } else { - $next_uri = $this->getRequest()->getRequestURI(); + + $next_uri = $request->getStr('next'); + if (!$next_uri) { + $next_uri_path = $this->getRequest()->getPath(); + if ($next_uri_path == '/login/') { + $next_uri = '/'; + } else { + $next_uri = $this->getRequest()->getRequestURI(); + } } if (!$request->isFormPost()) { @@ -139,10 +143,9 @@ final class PhabricatorLoginController $request->setCookie('phusr', $user->getUsername()); $request->setCookie('phsid', $session_key); - $uri = new PhutilURI('/login/validate/'); - $uri->setQueryParams( - array( - 'phusr' => $user->getUsername(), + $uri = id(new PhutilURI('/login/validate/')) + ->setQueryParams( + array('phusr' => $user->getUsername() )); return id(new AphrontRedirectResponse()) diff --git a/src/applications/pholio/controller/PholioMockViewController.php b/src/applications/pholio/controller/PholioMockViewController.php index f5f312f3e6..b9e6c569a1 100644 --- a/src/applications/pholio/controller/PholioMockViewController.php +++ b/src/applications/pholio/controller/PholioMockViewController.php @@ -8,6 +8,10 @@ final class PholioMockViewController extends PholioController { private $id; private $imageID; + public function shouldAllowPublic() { + return true; + } + public function willProcessRequest(array $data) { $this->id = $data['id']; $this->imageID = idx($data, 'imageID'); @@ -67,9 +71,11 @@ final class PholioMockViewController extends PholioController { require_celerity_resource('pholio-css'); require_celerity_resource('pholio-inline-comments-css'); - $output = new PholioMockImagesView(); - $output->setMock($mock); - $output->setImageID($this->imageID); + $output = id(new PholioMockImagesView()) + ->setRequestURI($request->getRequestURI()) + ->setUser($user) + ->setMock($mock) + ->setImageID($this->imageID); $xaction_view = id(new PhabricatorApplicationTransactionView()) ->setUser($this->getRequest()->getUser()) @@ -201,7 +207,8 @@ final class PholioMockViewController extends PholioController { ->setUser($user) ->setDraft($draft) ->setSubmitButtonName($button_name) - ->setAction($this->getApplicationURI('/comment/'.$mock->getID().'/')); + ->setAction($this->getApplicationURI('/comment/'.$mock->getID().'/')) + ->setRequestURI($this->getRequest()->getRequestURI()); return array( $header, diff --git a/src/applications/pholio/view/PholioMockImagesView.php b/src/applications/pholio/view/PholioMockImagesView.php index 72116f14ea..a8f3a6c209 100644 --- a/src/applications/pholio/view/PholioMockImagesView.php +++ b/src/applications/pholio/view/PholioMockImagesView.php @@ -4,6 +4,15 @@ final class PholioMockImagesView extends AphrontView { private $mock; private $imageID; + private $requestURI; + + public function setRequestURI(PhutilURI $request_uri) { + $this->requestURI = $request_uri; + return $this; + } + public function getRequestURI() { + return $this->requestURI; + } public function setImageID($image_id) { $this->imageID = $image_id; @@ -57,12 +66,16 @@ final class PholioMockImagesView extends AphrontView { ); } + $login_uri = id(new PhutilURI('/login/')) + ->setQueryParam('next', (string) $this->getRequestURI()); $config = array( 'mockID' => $mock->getID(), 'panelID' => $panel_id, 'viewportID' => $viewport_id, 'images' => $images, 'selectedID' => $selected_id, + 'loggedIn' => $this->getUser()->isLoggedIn(), + 'logInLink' => (string) $login_uri ); Javelin::initBehavior('pholio-mock-view', $config); diff --git a/src/applications/transactions/view/PhabricatorApplicationTransactionCommentView.php b/src/applications/transactions/view/PhabricatorApplicationTransactionCommentView.php index a943ec6179..ec26997456 100644 --- a/src/applications/transactions/view/PhabricatorApplicationTransactionCommentView.php +++ b/src/applications/transactions/view/PhabricatorApplicationTransactionCommentView.php @@ -15,6 +15,15 @@ class PhabricatorApplicationTransactionCommentView extends AphrontView { private $statusID; private $commentID; private $draft; + private $requestURI; + + public function setRequestURI(PhutilURI $request_uri) { + $this->requestURI = $request_uri; + return $this; + } + public function getRequestURI() { + return $this->requestURI; + } public function setDraft(PhabricatorDraft $draft) { $this->draft = $draft; @@ -45,6 +54,26 @@ class PhabricatorApplicationTransactionCommentView extends AphrontView { public function render() { + $user = $this->getUser(); + if (!$user->isLoggedIn()) { + $uri = id(new PhutilURI('/login/')) + ->setQueryParam('next', (string) $this->getRequestURI()); + return self::renderSingleView( + phutil_tag( + 'div', + array( + 'class' => 'login-to-comment' + ), + javelin_tag( + 'a', + array( + 'class' => 'button', + 'sigil' => 'workflow', + 'href' => $uri + ), + pht('Login to Comment')))); + } + $data = array(); $comment = $this->renderCommentPanel(); diff --git a/webroot/rsrc/css/aphront/form-view.css b/webroot/rsrc/css/aphront/form-view.css index abca6a6b2d..40eb7b0226 100644 --- a/webroot/rsrc/css/aphront/form-view.css +++ b/webroot/rsrc/css/aphront/form-view.css @@ -363,3 +363,8 @@ table.aphront-form-control-checkbox-layout th { .picker-open .calendar-button { border-left: 1px solid white; } + +.login-to-comment { + padding: 12px; + float: right; +} diff --git a/webroot/rsrc/js/application/pholio/behavior-pholio-mock-view.js b/webroot/rsrc/js/application/pholio/behavior-pholio-mock-view.js index 095722e014..4d5105fe93 100644 --- a/webroot/rsrc/js/application/pholio/behavior-pholio-mock-view.js +++ b/webroot/rsrc/js/application/pholio/behavior-pholio-mock-view.js @@ -303,6 +303,11 @@ JX.behavior('pholio-mock-view', function(config) { return; } is_dragging = false; + if (!config.loggedIn) { + new JX.Workflow(config.logInLink).start(); + return; + } + drag_end = get_image_xy(JX.$V(e)); var data = {mockID: config.mockID};