Skip to content

Commit

Permalink
Check for rails session cookie with security filter.
Browse files Browse the repository at this point in the history
This avoids a redirect by checking the rails session cookie even if there
is no symfony cookie.
  • Loading branch information
aepyornis committed Oct 27, 2016
1 parent 81f60f7 commit 630795c
Showing 1 changed file with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,33 @@ class sfGuardBasicSecurityFilter extends sfBasicSecurityFilter
{
public function execute ($filterChain)
{
$context = $this->getContext();
$user = $context->getUser();
$firstCall = $this->isFirstCall();

if ($firstCall && (!$user->isAuthenticated() || !$user->getGuardUser()))
{
if ($cookie = $context->getRequest()->getCookie('_lilsis_session'))
{
$sql = "SELECT data from sessions WHERE session_id = ?";
$db = Doctrine_Manager::connection();
$stmt = $db->execute($sql, array($cookie));
$results = $stmt->fetchAll();

if (count($results) > 0) {
$sf_user_id = json_decode($results[0]["data"])->value->sf_user_id;
$q = Doctrine_Query::create()
->from('sfGuardUser')
->where('id = ?', $sf_user_id);

$sf_user = $q->fetchOne();
if ($sf_user)
{
$user->signIn($sf_user);
}
}
}
}

// if ($this->isFirstCall() and !$this->getContext()->getUser()->isAuthenticated())
// {
Expand Down

0 comments on commit 630795c

Please sign in to comment.