Example #1
0
 public static function authenticate($params)
 {
     $parameters = array();
     $hashed_password = crypt($params['password'], 'armium');
     // let the salt be automatically generated
     $username = $params['username'];
     // if($_SESSION[$username])
     // {
     // 	return unserialize($_SESSION[$username]);
     // }
     try {
         $user = User::load_by_mail($username, $hashed_password);
         $data = $user->to_array();
         $_SESSION[$username] = serialize($data);
         return $data;
     } catch (Error $e) {
         throw new Error(400, 'Nombre de Usuario/password Incorrecto o Inexistente');
     }
 }
Example #2
0
 public function set_property($parameters)
 {
     $key = array_get($parameters, 'kind', '');
     $value = array_get($parameters, 'value', '');
     if ($key == 'is_released' && $value == 'NO') {
         $user_data = User::load_by_mail($_SERVER['REMOTE_USER'])->to_array();
         foreach ($user_data['permissions'] as $key2 => $value2) {
             $permissions[] = $value2['description'];
         }
         if (!in_array('is_woa', $permissions)) {
             if (!in_array('is_onlinemex', $permissions)) {
                 return false;
             }
         }
     }
     if (!is_string($value) || strlen($value) == 0) {
         throw new Error(400, 'Incorrect Property Value');
     }
     if (!is_string($value) || strlen($value) == 0) {
         throw new Error(400, 'Incorrect Property Value');
     }
     switch ($key) {
         case 'is_visible':
         case 'maintenance':
         case 'is_released':
         case 'is_qa':
         case 'is_cc':
             /* we are good */
             if ($value != 'YES' && $value != 'NO') {
                 throw new Error(400, 'Incorrect Key Value ' . $value);
             }
             break;
         default:
             throw new Error(400, 'The Key Description ' . $key . ' Do Not Exist');
             break;
     }
     $sql = 'UPDATE `' . DB_TUNA . '`.`client_ids` SET `' . $key . '` = "' . $value . '" WHERE `id`=' . $this->id;
     $GLOBALS[TUNA_RW]->query($sql);
     /***SYNC_TUNA**/
     if (SYNC_TUNA_ACTIVE) {
         TunaCoupler::sync_clientid_set_property($key, $value, $this->id);
     }
     /***SYNC_TUNA**/
     return true;
 }