Esempio n. 1
0
 function brand_list_user_post()
 {
     $key_empty = '';
     if (empty($this->post('userid'))) {
         $key_empty = 'userid';
     }
     if (empty($this->post('access_token'))) {
         $key_empty = 'access_token';
     }
     if (!empty($key_empty)) {
         $this->response(['status' => FALSE, 'message' => $key_empty . ' not found'], REST_Controller::HTTP_BAD_REQUEST);
         // NOT_FOUND (404) being the HTTP response code
     }
     if (!is_access_token_valid($this->post('userid'), $this->post('access_token'))) {
         $this->response(['status' => FALSE, 'message' => 'Access token not valid'], REST_Controller::HTTP_BAD_REQUEST);
         // NOT_FOUND (404) being the HTTP response code
     }
     $result = $this->brand->brand_list_user($this->post('userid'));
     if ($result) {
         $this->response(['status' => TRUE, 'brand_list' => $result], REST_Controller::HTTP_OK);
     } else {
         $this->response(['status' => False, 'Message' => "Brand list not found."], REST_Controller::HTTP_BAD_REQUEST);
     }
 }
Esempio n. 2
0
 function password_change_post()
 {
     $key_empty = '';
     if (empty($this->post('userid'))) {
         $key_empty = 'userid';
     }
     if (empty($this->post('access_token'))) {
         $key_empty = 'access_token';
     }
     if (empty($this->post('password_current'))) {
         $key_empty = 'password_current';
     }
     if (empty($this->post('password_new'))) {
         $key_empty = 'password_new';
     }
     if (!empty($key_empty)) {
         $this->response(['status' => FALSE, 'message' => $key_empty . ' not found'], REST_Controller::HTTP_BAD_REQUEST);
         // NOT_FOUND (404) being the HTTP response code
     }
     if (!is_access_token_valid($this->post('userid'), $this->post('access_token'))) {
         $this->response(['status' => FALSE, 'message' => 'Access token not valid'], REST_Controller::HTTP_BAD_REQUEST);
         // NOT_FOUND (404) being the HTTP response code
     }
     $password_current = encrypt_text($this->post('password_current'));
     if (empty($this->user->password_current_match($this->post('userid'), $password_current))) {
         $this->response(['status' => FALSE, 'message' => 'Current password not correct.'], REST_Controller::HTTP_BAD_REQUEST);
         // NOT_FOUND (404) being the HTTP response code
     } else {
         $password_new = encrypt_text($this->post('password_new'));
         if ($this->user->password_change($this->post('userid'), $password_new)) {
             $this->response(['status' => TRUE], REST_Controller::HTTP_OK);
             // NOT_FOUND (404) being the HTTP response code
         } else {
             $this->response(['status' => FALSE, 'message' => 'Password not change.'], REST_Controller::HTTP_BAD_REQUEST);
             // NOT_FOUND (404) being the HTTP response code
         }
     }
 }
Esempio n. 3
0
 function relation_create_post()
 {
     $key_empty = '';
     if (empty($this->post('userid'))) {
         $key_empty = 'userid';
     }
     if (empty($this->post('access_token'))) {
         $key_empty = 'access_token';
     }
     if (empty($this->post('contact_number'))) {
         $key_empty = 'contact_number';
     }
     if (empty($this->post('relation_type'))) {
         $key_empty = 'relation_type';
     }
     if (empty($this->post('group_id'))) {
         $group_id = NULL;
     } else {
         $group_id = $this->post('group_id');
     }
     if (!empty($key_empty)) {
         $this->response(['status' => FALSE, 'message' => $key_empty . ' not found'], REST_Controller::HTTP_BAD_REQUEST);
         // NOT_FOUND (404) being the HTTP response code
     }
     if (!is_access_token_valid($this->post('userid'), $this->post('access_token'))) {
         $this->response(['status' => FALSE, 'message' => 'Access token not valid'], REST_Controller::HTTP_BAD_REQUEST);
         // NOT_FOUND (404) being the HTTP response code
     }
     $user_id_from_contact = $this->common->get_user_id_from_contact_number($this->post('contact_number'));
     if (empty($user_id_from_contact)) {
         $this->response(['status' => FALSE, 'message' => 'User not exist in application.'], REST_Controller::HTTP_BAD_REQUEST);
         // NOT_FOUND (404) being the HTTP response code
     } else {
         $relation_id = $this->group->relation_create($this->post('userid'), $user_id_from_contact, $this->post('relation_type'), $group_id);
         if ($relation_id) {
             $this->response(['status' => TRUE], REST_Controller::HTTP_CREATED);
         } else {
             $this->response(['status' => FALSE, 'message' => 'Relation not created.'], REST_Controller::HTTP_BAD_REQUEST);
         }
     }
 }