forked from wallabag/wallabag
Merge branch '2.6' into merge-2.6-in-master
This commit is contained in:
@ -2,6 +2,7 @@
|
||||
|
||||
namespace Wallabag\CoreBundle\Helper;
|
||||
|
||||
use GuzzleHttp\Psr7\Uri;
|
||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||
use Wallabag\CoreBundle\Entity\Config;
|
||||
@ -23,16 +24,23 @@ class Redirect
|
||||
|
||||
/**
|
||||
* @param string $url URL to redirect
|
||||
* @param string $fallback Fallback URL if $url is null
|
||||
* @param bool $ignoreActionMarkAsRead Ignore configured action when mark as read
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function to($url, $fallback = '', $ignoreActionMarkAsRead = false)
|
||||
public function to($url, $ignoreActionMarkAsRead = false)
|
||||
{
|
||||
$user = $this->tokenStorage->getToken() ? $this->tokenStorage->getToken()->getUser() : null;
|
||||
|
||||
if (!$user instanceof User) {
|
||||
if (null === $url) {
|
||||
return $this->router->generate('homepage');
|
||||
}
|
||||
|
||||
if (!Uri::isAbsolutePathReference(new Uri($url))) {
|
||||
return $this->router->generate('homepage');
|
||||
}
|
||||
|
||||
return $url;
|
||||
}
|
||||
|
||||
@ -41,14 +49,14 @@ class Redirect
|
||||
return $this->router->generate('homepage');
|
||||
}
|
||||
|
||||
if (null !== $url) {
|
||||
return $url;
|
||||
}
|
||||
|
||||
if ('' === $fallback) {
|
||||
if (null === $url) {
|
||||
return $this->router->generate('homepage');
|
||||
}
|
||||
|
||||
return $fallback;
|
||||
if (!Uri::isAbsolutePathReference(new Uri($url))) {
|
||||
return $this->router->generate('homepage');
|
||||
}
|
||||
|
||||
return $url;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user