예제 #1
0
 function process(Mobile_API_Request $request)
 {
     $response = new Mobile_API_Response();
     $username = $request->get('username');
     $password = $request->get('password');
     $current_user = CRMEntity::getInstance('Users');
     $current_user->column_fields['user_name'] = $username;
     if (vtlib_isModuleActive('Mobile') === false) {
         $response->setError(1501, 'Service not available');
         return $response;
     }
     if (!$current_user->doLogin($password)) {
         $response->setError(1210, 'Authentication Failed');
     } else {
         // Start session now
         $sessionid = Mobile_API_Session::init();
         if ($sessionid === false) {
             echo "Session init failed {$sessionid}\n";
         }
         $current_user->id = $current_user->retrieve_user_id($username);
         $current_user->retrieveCurrentUserInfoFromFile($current_user->id);
         $this->setActiveUser($current_user);
         $result = array();
         $result['login'] = array('userid' => $current_user->id, 'crm_tz' => DateTimeField::getDBTimeZone(), 'user_tz' => $current_user->time_zone, 'user_currency' => $current_user->currency_code, 'session' => $sessionid, 'vtiger_version' => Mobile_WS_Utils::getVtigerVersion(), 'date_format' => $current_user->date_format, 'mobile_module_version' => Mobile_WS_Utils::getVersion());
         $response->setResult($result);
         $this->postProcess($response);
     }
     return $response;
 }
예제 #2
0
파일: Login.php 프로젝트: kduqi/corebos
 function process(Mobile_API_Request $request)
 {
     $response = new Mobile_API_Response();
     $username = $request->get('username');
     $password = $request->get('password');
     $current_user = CRMEntity::getInstance('Users');
     $current_user->column_fields['user_name'] = $username;
     if (vtlib_isModuleActive('Mobile') === false) {
         $response->setError(1501, 'Service not available');
         return $response;
     }
     if (!$current_user->load_user($password) || !$current_user->authenticated) {
         global $mod_strings;
         $response->setError(1210, $mod_strings['ERR_INVALID_PASSWORD']);
     } else {
         // Start session now
         $sessionid = Mobile_API_Session::init();
         if ($sessionid === false) {
             echo "Session init failed {$sessionid}\n";
         }
         include_once 'config.php';
         global $application_unique_key;
         $current_user->id = $current_user->retrieve_user_id($username);
         $this->setActiveUser($current_user);
         $_SESSION["authenticated_user_id"] = $current_user->id;
         $_SESSION["app_unique_key"] = $application_unique_key;
         $result = array();
         $result['login'] = array('userid' => $current_user->id, 'crm_tz' => DateTimeField::getDBTimeZone(), 'user_tz' => $current_user->time_zone, 'session' => $sessionid, 'language' => $current_user->language, 'vtiger_version' => Mobile_WS_Utils::getVtigerVersion(), 'mobile_module_version' => Mobile_WS_Utils::getVersion());
         $response->setResult($result);
         $this->postProcess($response);
     }
     return $response;
 }