Ignore:
Timestamp:
04/27/12 15:18:00 (12 years ago)
Author:
niltonneto
Message:

Ticket #2507 - Modificada implementação para tratamento de erros por Exception.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sandbox/webservice/api/rest/core/LoginResource.php

    r6019 r6061  
    44        public function post($request){ 
    55                // to Receive POST Params (use $this->params) 
    6                 parent::post($request);  
    7                  
    8                 if(!$this-> isLoggedIn())  
    9                 {                                        
    10                         if($sessionid = $GLOBALS['phpgw']->session->create($this->getParam('user'), $this->getParam('password')))                                        
    11                         {                                
    12                                 $result = array( 
    13                                         'auth'                  => $sessionid.":".$GLOBALS['phpgw']->session->kp3, 
    14                                         'profile'               => array($this->getUserProfile()) 
    15                                 ); 
    16                                 $this->setError(false); 
    17                                 $this->setResult($result); 
    18                         } 
    19                         else 
    20                         {        
    21                                 $this->setError($GLOBALS['phpgw']->session->cd_reason); 
    22                         }                        
     6                parent::post($request); 
     7                if($sessionid = $GLOBALS['phpgw']->session->create($this->getParam('user'), $this->getParam('password'))) 
     8                { 
     9                        $result = array( 
     10                                'auth'                  => $sessionid.":".$GLOBALS['phpgw']->session->kp3, 
     11                                'profile'               => array($this->getUserProfile()) 
     12                        ); 
     13                        $this->setResult($result); 
    2314                } 
    2415                else 
    2516                { 
    26                         $result = array('auth' =>  $this->getParam('auth')); 
    27                         $this->setResult($result); 
     17                        throw new ResponseException("",$GLOBALS['phpgw']->session->cd_reason); 
    2818                } 
    29                  
    30                 //to Send Response (JSON RPC format) 
    31                 return $this->getResponse();             
     19                return $this->getResponse(); 
    3220        }        
    3321 
Note: See TracChangeset for help on using the changeset viewer.