mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-24 22:40:55 +01:00
When redirecting to acquire file access tokens, retain 'download' parameter
Summary: Fixes T7398. Previously, we would redirect to get a token and then redirect back to make use of it, but lose "download" in the process, and thus not get the correct "Content-Disposition" header. Test Plan: Clicked "Download" on a lightboxed file. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T7398 Differential Revision: https://secure.phabricator.com/D11915
This commit is contained in:
parent
d1eda610fa
commit
ed49b41e91
1 changed files with 21 additions and 2 deletions
|
@ -73,9 +73,13 @@ final class PhabricatorFileDataController extends PhabricatorFileController {
|
||||||
|
|
||||||
// if the user can see the file, generate a token;
|
// if the user can see the file, generate a token;
|
||||||
// redirect to the alt domain with the token;
|
// redirect to the alt domain with the token;
|
||||||
|
$token_uri = $file->getCDNURIWithToken();
|
||||||
|
$token_uri = new PhutilURI($token_uri);
|
||||||
|
$token_uri = $this->addURIParameters($token_uri);
|
||||||
|
|
||||||
return id(new AphrontRedirectResponse())
|
return id(new AphrontRedirectResponse())
|
||||||
->setIsExternal(true)
|
->setIsExternal(true)
|
||||||
->setURI($file->getCDNURIWithToken());
|
->setURI($token_uri);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// We are using the alternate domain
|
// We are using the alternate domain
|
||||||
|
@ -93,7 +97,7 @@ final class PhabricatorFileDataController extends PhabricatorFileController {
|
||||||
|
|
||||||
$acquire_token_uri = id(new PhutilURI($file->getViewURI()))
|
$acquire_token_uri = id(new PhutilURI($file->getViewURI()))
|
||||||
->setDomain($main_domain);
|
->setDomain($main_domain);
|
||||||
|
$acquire_token_uri = $this->addURIParameters($acquire_token_uri);
|
||||||
|
|
||||||
if ($this->token) {
|
if ($this->token) {
|
||||||
// validate the token, if it is valid, continue
|
// validate the token, if it is valid, continue
|
||||||
|
@ -186,4 +190,19 @@ final class PhabricatorFileDataController extends PhabricatorFileController {
|
||||||
|
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add passthrough parameters to the URI so they aren't lost when we
|
||||||
|
* redirect to acquire tokens.
|
||||||
|
*/
|
||||||
|
private function addURIParameters(PhutilURI $uri) {
|
||||||
|
$request = $this->getRequest();
|
||||||
|
|
||||||
|
if ($request->getBool('download')) {
|
||||||
|
$uri->setQueryParam('download', 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $uri;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue