Exemple #1
0
 public function profile_post()
 {
     $this->auth(true);
     try {
         if (!$this->post()) {
             throw new Exception('Empty Request', 400);
         }
         $data = $this->post();
         unset($data['device_token']);
         $device_token = $this->post('device_token');
         $reg_result = $this->model->register($data);
         if ($reg_result['errors']) {
             $this->response($reg_result, 400);
         }
         $reg_result['profile'] = $this->model->get_extended_profile($reg_result['profile']['id']);
         if ($device_token) {
             $this->device_tokens_model->add_token($reg_result['profile']['id'], $device_token);
         }
         $this->response($reg_result, 200);
     } catch (Exception $e) {
         $this->response($e->getMessage(), $e->getCode());
     }
 }