Skip to content

Instantly share code, notes, and snippets.

@odracci
Created May 27, 2011 22:36
Show Gist options
  • Save odracci/996333 to your computer and use it in GitHub Desktop.
Save odracci/996333 to your computer and use it in GitHub Desktop.
<?php
/**
* @Route("/demo/secured")
*/
class SecuredController extends Controller
{
/**
* @Route("/login", name="_demo_login")
* @Template()
*/
public function loginAction()
{
if ($this->get('request')->attributes->has(SecurityContext::AUTHENTICATION_ERROR)) {
$error = $this->get('request')->attributes->get(SecurityContext::AUTHENTICATION_ERROR);
} else {
$error = $this->get('request')->getSession()->get(SecurityContext::AUTHENTICATION_ERROR);
}
return array(
'last_username' => $this->get('request')->getSession()->get(SecurityContext::LAST_USERNAME),
'error' => $error,
);
}
}
/**
* @Route("/demo/secured")
*/
class SecuredController extends Controller
{
/**
* @Route("/login", name="_demo_login")
* @Template()
*/
public function loginAction()
{
if ($this->getRequestService()->attributes->has(SecurityContext::AUTHENTICATION_ERROR)) {
$error = $this->getRequestService()->attributes->get(SecurityContext::AUTHENTICATION_ERROR);
} else {
$error = $this->getRequestService()->getSession()->get(SecurityContext::AUTHENTICATION_ERROR);
}
return array(
'last_username' => $this->getRequestService()->getSession()->get(SecurityContext::LAST_USERNAME),
'error' => $error,
);
}
/**
*
* @return Symfony\Component\HttpFoundation\Request
*/
public function getRequestService() {
return $this->request;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment