-
Notifications
You must be signed in to change notification settings - Fork 343
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FIX] some shortlinks not working without login
- Loading branch information
Showing
4 changed files
with
56 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,11 +20,13 @@ | |
|
||
namespace ILIAS\StaticURL\Handler; | ||
|
||
use ILIAS\StaticURL\Request\Request; | ||
use ILIAS\StaticURL\Request\RequestBuilder; | ||
use ILIAS\Data\URI; | ||
use ILIAS\StaticURL\Response\Factory; | ||
use ILIAS\StaticURL\Context; | ||
use ILIAS\StaticURL\Builder\StandardURIBuilder; | ||
use ILIAS\StaticURL\Response\MaybeCanHandlerAfterLogin; | ||
|
||
/** | ||
* @author Fabian Schmid <[email protected]> | ||
|
@@ -48,7 +50,10 @@ public function __construct( | |
} | ||
} | ||
|
||
public function performRedirect(URI $base_uri): never | ||
/** | ||
* @return never | ||
*/ | ||
public function performRedirect(URI $base_uri): void | ||
{ | ||
$http = $this->context->http(); | ||
$ctrl = $this->context->refinery(); | ||
|
@@ -58,12 +63,12 @@ public function performRedirect(URI $base_uri): never | |
$this->context->refinery(), | ||
$this->handlers | ||
); | ||
if (!$request instanceof \ILIAS\StaticURL\Request\Request) { | ||
if (!$request instanceof Request) { | ||
throw new \RuntimeException('No request could be built'); | ||
} | ||
|
||
$handler = $this->handlers[$request->getNamespace()] ?? null; | ||
if (!$handler instanceof \ILIAS\StaticURL\Handler\Handler) { | ||
if (!$handler instanceof Handler) { | ||
throw new \InvalidArgumentException('No handler found for namespace ' . $request->getNamespace()); | ||
} | ||
$response = $handler->handle($request, $this->context, $this->response_factory); | ||
|
@@ -74,7 +79,10 @@ public function performRedirect(URI $base_uri): never | |
} | ||
|
||
// Check access to target | ||
if (!$this->context->isUserLoggedIn() && !$this->context->isPublicSectionActive()) { | ||
if ( | ||
$response instanceof MaybeCanHandlerAfterLogin | ||
|| (!$this->context->isUserLoggedIn() && !$this->context->isPublicSectionActive()) | ||
) { | ||
$uri_builder = new StandardURIBuilder(ILIAS_HTTP_PATH, false); | ||
$target = $uri_builder->buildTarget( | ||
$request->getNamespace(), | ||
|
@@ -88,7 +96,7 @@ public function performRedirect(URI $base_uri): never | |
} else { | ||
// Perform Redirect | ||
$uri_path = $response->getURIPath(); | ||
$full_uri = $base_uri . '/' . trim($uri_path, '/'); | ||
$full_uri = $base_uri . '/' . trim((string) $uri_path, '/'); | ||
} | ||
|
||
$http->saveResponse( | ||
|
@@ -105,7 +113,7 @@ public function performRedirect(URI $base_uri): never | |
private function appendUnknownParameters(Context $context, string $full_uri): string | ||
{ | ||
if ($context->http()->wrapper()->query()->has('soap_pw')) { | ||
$full_uri = \ilUtil::appendUrlParameterString( | ||
return \ilUtil::appendUrlParameterString( | ||
$full_uri, | ||
'soap_pw=' . $context->http()->wrapper()->query()->retrieve( | ||
'soap_pw', | ||
|
@@ -114,7 +122,7 @@ private function appendUnknownParameters(Context $context, string $full_uri): st | |
); | ||
} | ||
if ($context->http()->wrapper()->query()->has('ext_uid')) { | ||
$full_uri = ilUtil::appendUrlParameterString( | ||
return ilUtil::appendUrlParameterString( | ||
$full_uri, | ||
'ext_uid=' . $context->http()->wrapper()->query()->retrieve( | ||
'ext_uid', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
components/ILIAS/StaticURL/src/Response/MaybeCanHandlerAfterLogin.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of ILIAS, a powerful learning management system | ||
* published by ILIAS open source e-Learning e.V. | ||
* | ||
* ILIAS is licensed with the GPL-3.0, | ||
* see https://www.gnu.org/licenses/gpl-3.0.en.html | ||
* You should have received a copy of said license along with the | ||
* source code, too. | ||
* | ||
* If this is not the case or you just want to try ILIAS, you'll find | ||
* us at: | ||
* https://www.ilias.de | ||
* https://github.com/ILIAS-eLearning | ||
* | ||
*********************************************************************/ | ||
|
||
namespace ILIAS\StaticURL\Response; | ||
|
||
/** | ||
* @author Fabian Schmid <[email protected]> | ||
*/ | ||
class MaybeCanHandlerAfterLogin implements Response | ||
{ | ||
public function getURIPath(): ?string | ||
{ | ||
return null; | ||
} | ||
|
||
public function targetCanBeReached(): bool | ||
{ | ||
return true; | ||
} | ||
|
||
} |