symfony
[ class tree: symfony ] [ index: symfony ] [ all elements ]

Source for file actions.class.php

Documentation is available at actions.class.php

  1. <?php
  2. require_once(sfConfig::get('sf_plugins_dir').'/sfGuardPlugin/modules/sfGuardAuth/lib/BasesfGuardAuthActions.class.php');
  3.  
  4. /**
  5.  *
  6.  * @package    symfony
  7.  * @subpackage plugin
  8.  * @author     Fabien Potencier <fabien.potencier@symfony-project.com>
  9.  * @version    SVN: $Id: actions.class.php 2278 2006-10-01 13:30:31Z fabien $
  10.  */
  11. class sfGuardAuthActions extends BasesfGuardAuthActions
  12. {
  13.     public function executeSignin($request){
  14.         $user $this->getUser();
  15.  
  16.  
  17.         if ($user->isAuthenticated()) return $this->redirect('@homepage');
  18.         
  19.         if($this->getRequest()->isXmlHttpRequest(== true){
  20.  
  21.  
  22.             $class sfConfig::get('app_sf_guard_plugin_signin_form''sfGuardFormSignin');
  23.             $this->form new $class();
  24.  
  25.             if ($request->isMethod('post')){
  26.                 $this->form->bind($request->getParameter('signin'));
  27.  
  28.                 if ($this->form->isValid()){
  29.                     
  30.                     $values $this->form->getValues();
  31.                     
  32.                     $this->getUser()->signin($values['user']array_key_exists('remember'$values$values['remember'false);
  33.                 // always redirect to a URL set in app.yml
  34.                 // or to the referer
  35.                 // or to the homepage
  36.                     $signinUrl sfConfig::get('app_sf_guard_plugin_success_signin_url'$user->getReferer('@homepage'));
  37.  
  38.                     $this->getUser()->initVncToken();
  39.  
  40.                 // return $this->redirect($signinUrl);
  41.                     $response array("success" => true"redirect" => $signinUrl);
  42.                     $result=json_encode($response);
  43.                     $this->getResponse()->setHttpHeader("X-JSON"'()')// set a header, although it is empty...
  44.                     return $this->renderText($result);
  45.  
  46.                 }
  47.                 else// NOT valid
  48.                     foreach ($this->form->getErrorSchema(as $field => $error{
  49.                         $errors[$field$error->getMessage();
  50.  
  51.                     }                 
  52.                     $this->errors $errors;
  53.                     //  return sfView::ERROR;
  54.                     $response=array('success' => false"errors" => $this->errors);
  55.  
  56.                     $result=json_encode($response);
  57.                     $this->getResponse()->setHttpHeader("X-JSON"'()')// set a header, although it is empty...
  58.                     $this->getResponse()->setStatusCode(401);
  59.                     return $this->renderText($result);
  60.                 }
  61.  
  62.  
  63.             //END POST           
  64.         // END XmlHttpRequest
  65.         
  66.         parent::executeSignin($request);
  67.  
  68.   }
  69.  
  70.  
  71.  
  72. }

Documentation generated on Fri, 19 Jun 2009 10:45:48 +0100 by phpDocumentor 1.4.2