Advertisement
Guest User

Login with a Symfony User

a guest
Aug 4th, 2016
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.37 KB | None | 0 0
  1. public function executeLogin(sfWebRequest $request)
  2.   {
  3.       $user = $_GET['username'];
  4.       $passwd = $_GET['password'];
  5.       $hash = $_GET['hash'];
  6.      
  7.       $xml = '<?xml version="1.0" encoding="UTF-8"?>';
  8.       //$resultArr = Array();
  9.       $comphash = sha1("DFh3X98njaW4tb082ky".$passwd.$user."mNGwn3D8Iodq28ZXAsf35Nb");
  10.  
  11.       if($comphash == $hash)
  12.       {
  13.           $cuser = Doctrine_Query::create()
  14.             ->from('sfGuardUser p')
  15.             ->where('p.username = ?', $user)
  16.             ->andWhere('p.is_active = ?', 1)
  17.             ->fetchOne();
  18.          
  19.           if($cuser)
  20.           {
  21.               $passhash = sha1($cuser->getSalt().$passwd);
  22.               $passhash2 = sha1($passwd);
  23.              
  24.               $cuser = Doctrine_Query::create()
  25.                 ->from('sfGuardUser p')
  26.                 ->where('p.username = ?', $user)
  27.                 ->andWhere('p.password = ?', $passhash)
  28.                 ->andWhere('p.is_active = ?', 1)
  29.                 ->fetchOne();
  30.                
  31.               if($cuser)
  32.               {
  33.                   $this->getUser()->signIn($cuser);
  34.                   $this->redirect('dashboard/init');
  35.                   $xml = $xml.'<result>00001</result>';              
  36.               }
  37.               else
  38.                   $xml = $xml.'<result>01004</result>';  
  39.           }
  40.       }
  41.       else
  42.               $xml = $xml.'<result>01006</result>';    
  43.              
  44.      
  45.       $this->getResponse()->setContentType('application/xml');
  46.      
  47.       // HAY QUE PONER ESTA LINEA, PORQUE SINO AΓ‘ADE UN INTRO AL PRINCIPIO DEL FICHERO.
  48.       ob_end_clean();
  49.      
  50.       $this->setLayout(false);
  51.       return $this->renderText($xml);
  52.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement