diff --git a/apps/files_sharing/lib/Controller/ShareController.php b/apps/files_sharing/lib/Controller/ShareController.php index 1f8864fc5f..856f001bbb 100644 --- a/apps/files_sharing/lib/Controller/ShareController.php +++ b/apps/files_sharing/lib/Controller/ShareController.php @@ -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; diff --git a/core/routes.php b/core/routes.php index 97a8621fc3..d357fd45f9 100644 --- a/core/routes.php +++ b/core/routes.php @@ -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');