Skip to content

Commit

Permalink
add storage of the target path in the session
Browse files Browse the repository at this point in the history
  • Loading branch information
darrylhein committed Feb 6, 2020
1 parent e3d23c2 commit afec211
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion Controller/SecurityController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@
use FOS\UserBundle\Controller\SecurityController as BaseSecurityController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Security\Core\Security;
use Symfony\Component\Security\Http\Util\TargetPathTrait;

class SecurityController extends BaseSecurityController
{
use TargetPathTrait;

/**
* The target path, used during the login and passed to the login view.
* @var string
Expand All @@ -33,6 +36,14 @@ public function loginAction(Request $request)
$this->pullUsernameFromQuery($request);
$this->pullTargetPathFromQuery($request);

if ($this->targetPath) {
$this->saveTargetPath(
$request->getSession(),
'main',
$this->targetPath
);
}

return parent::loginAction($request);
}

Expand Down Expand Up @@ -76,6 +87,9 @@ protected function pullUsernameFromQuery(Request $request)
protected function pullTargetPathFromQuery(Request $request)
{
$targetPath = $request->query->get('target_path');
if (!$targetPath) {
$targetPath = $request->query->get('_target_path');
}

if ($targetPath) {
$this->targetPath = $targetPath;
Expand All @@ -99,4 +113,4 @@ protected function isRegistrationEnabled()

return (null !== $routes->get('fos_user_registration_register'));
}
}
}

0 comments on commit afec211

Please sign in to comment.