Sharing: redirect to download after authentification if requested
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
This commit is contained in:
parent
0cfdf4748f
commit
fb890807c0
|
@ -170,10 +170,11 @@ class ShareController extends Controller {
|
|||
*
|
||||
* Authenticates against password-protected shares
|
||||
* @param string $token
|
||||
* @param string $redirect
|
||||
* @param string $password
|
||||
* @return RedirectResponse|TemplateResponse|NotFoundResponse
|
||||
*/
|
||||
public function authenticate($token, $password = '') {
|
||||
public function authenticate($token, $redirect, $password = '') {
|
||||
|
||||
// Check whether share exists
|
||||
try {
|
||||
|
@ -184,7 +185,9 @@ class ShareController extends Controller {
|
|||
|
||||
$authenticate = $this->linkShareAuth($share, $password);
|
||||
|
||||
if($authenticate === true) {
|
||||
if ($authenticate === true && $redirect === 'download') {
|
||||
return new RedirectResponse($this->urlGenerator->linkToRoute('files_sharing.sharecontroller.downloadShare', array('token' => $token)));
|
||||
} else if ($authenticate === true) {
|
||||
return new RedirectResponse($this->urlGenerator->linkToRoute('files_sharing.sharecontroller.showShare', array('token' => $token)));
|
||||
}
|
||||
|
||||
|
@ -294,7 +297,7 @@ class ShareController extends Controller {
|
|||
// Share is password protected - check whether the user is permitted to access the share
|
||||
if ($share->getPassword() !== null && !$this->linkShareAuth($share)) {
|
||||
return new RedirectResponse($this->urlGenerator->linkToRoute('files_sharing.sharecontroller.authenticate',
|
||||
array('token' => $token)));
|
||||
array('token' => $token, 'redirect' => 'preview')));
|
||||
}
|
||||
|
||||
if (!$this->validateShare($share)) {
|
||||
|
@ -480,7 +483,7 @@ class ShareController extends Controller {
|
|||
// Share is password protected - check whether the user is permitted to access the share
|
||||
if ($share->getPassword() !== null && !$this->linkShareAuth($share)) {
|
||||
return new RedirectResponse($this->urlGenerator->linkToRoute('files_sharing.sharecontroller.authenticate',
|
||||
['token' => $token]));
|
||||
['token' => $token, 'redirect' => 'download']));
|
||||
}
|
||||
|
||||
$files_list = null;
|
||||
|
|
|
@ -116,7 +116,7 @@ $this->create('files_sharing.sharecontroller.showShare', '/s/{token}')->action(f
|
|||
throw new \OC\HintException('App file sharing is not enabled');
|
||||
}
|
||||
});
|
||||
$this->create('files_sharing.sharecontroller.authenticate', '/s/{token}/authenticate')->post()->action(function($urlParams) {
|
||||
$this->create('files_sharing.sharecontroller.authenticate', '/s/{token}/authenticate/{redirect}')->post()->action(function($urlParams) {
|
||||
if (class_exists(\OCA\Files_Sharing\AppInfo\Application::class, false)) {
|
||||
$app = new \OCA\Files_Sharing\AppInfo\Application($urlParams);
|
||||
$app->dispatch('ShareController', 'authenticate');
|
||||
|
@ -124,7 +124,7 @@ $this->create('files_sharing.sharecontroller.authenticate', '/s/{token}/authenti
|
|||
throw new \OC\HintException('App file sharing is not enabled');
|
||||
}
|
||||
});
|
||||
$this->create('files_sharing.sharecontroller.showAuthenticate', '/s/{token}/authenticate')->get()->action(function($urlParams) {
|
||||
$this->create('files_sharing.sharecontroller.showAuthenticate', '/s/{token}/authenticate/{redirect}')->get()->action(function($urlParams) {
|
||||
if (class_exists(\OCA\Files_Sharing\AppInfo\Application::class, false)) {
|
||||
$app = new \OCA\Files_Sharing\AppInfo\Application($urlParams);
|
||||
$app->dispatch('ShareController', 'showAuthenticate');
|
||||
|
|
Loading…
Reference in New Issue