Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15403207
D10215.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D10215.diff
View Options
diff --git a/src/applications/files/controller/PhabricatorFileController.php b/src/applications/files/controller/PhabricatorFileController.php
--- a/src/applications/files/controller/PhabricatorFileController.php
+++ b/src/applications/files/controller/PhabricatorFileController.php
@@ -2,17 +2,6 @@
abstract class PhabricatorFileController extends PhabricatorController {
- public function buildApplicationCrumbs() {
- $crumbs = parent::buildApplicationCrumbs();
- $crumbs->addAction(
- id(new PHUIListItemView())
- ->setName(pht('Upload File'))
- ->setIcon('fa-upload')
- ->setHref($this->getApplicationURI('/upload/')));
-
- return $crumbs;
- }
-
protected function buildSideNavView() {
$menu = $this->buildMenu($for_devices = false);
return AphrontSideNavFilterView::newFromMenu($menu);
diff --git a/src/applications/files/controller/PhabricatorFileDataController.php b/src/applications/files/controller/PhabricatorFileDataController.php
--- a/src/applications/files/controller/PhabricatorFileDataController.php
+++ b/src/applications/files/controller/PhabricatorFileDataController.php
@@ -90,23 +90,46 @@
return $error_response;
}
+ $acquire_token_uri = id(new PhutilURI($file->getViewURI()))
+ ->setDomain($main_domain);
+
+
if ($this->token) {
// validate the token, if it is valid, continue
$validated_token = $file->validateOneTimeToken($this->token);
if (!$validated_token) {
- return new Aphront403Response();
+ $dialog = $this->newDialog()
+ ->setShortTitle(pht('Expired File'))
+ ->setTitle(pht('File Link Has Expired'))
+ ->appendParagraph(
+ pht(
+ 'The link you followed to view this file is invalid or '.
+ 'expired.'))
+ ->appendParagraph(
+ pht(
+ 'Continue to generate a new link to the file. You may be '.
+ 'required to log in.'))
+ ->addCancelButton(
+ $acquire_token_uri,
+ pht('Continue'));
+
+ // Build an explicit response so we can respond with HTTP/403 instead
+ // of HTTP/200.
+ $response = id(new AphrontDialogResponse())
+ ->setDialog($dialog)
+ ->setHTTPResponseCode(403);
+
+ return $response;
}
// return the file data without cache headers
$cache_response = false;
} else if (!$file->getCanCDN()) {
// file cannot be served via cdn, and no token given
// redirect to the main domain to aquire a token
- $file_uri = id(new PhutilURI($file->getViewURI()))
- ->setDomain($main_domain);
return id(new AphrontRedirectResponse())
- ->setURI($file_uri);
+ ->setURI($acquire_token_uri);
}
}
diff --git a/src/applications/files/controller/PhabricatorFileListController.php b/src/applications/files/controller/PhabricatorFileListController.php
--- a/src/applications/files/controller/PhabricatorFileListController.php
+++ b/src/applications/files/controller/PhabricatorFileListController.php
@@ -22,4 +22,15 @@
return $this->delegateToController($controller);
}
+ public function buildApplicationCrumbs() {
+ $crumbs = parent::buildApplicationCrumbs();
+ $crumbs->addAction(
+ id(new PHUIListItemView())
+ ->setName(pht('Upload File'))
+ ->setIcon('fa-upload')
+ ->setHref($this->getApplicationURI('/upload/')));
+
+ return $crumbs;
+ }
+
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Mar 19, 2:12 AM (2 w, 6 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7388513
Default Alt Text
D10215.diff (3 KB)
Attached To
Mode
D10215: Generate a 403 page with a nice dialog when a file token is invalid
Attached
Detach File
Event Timeline
Log In to Comment