示例#1
0
 /**
  * API Change password
  * @method POST
  * @param old_pass (required)
  * @param new_pass (required)
  *
  * @return int|null
  */
 function changePassword()
 {
     $this->checkTokenValidation();
     if (empty($_POST)) {
         /**
          * Return error if request method is not POST.
          */
         $this->setError('E403');
         return null;
     }
     $old_password = $_POST['old_pass'];
     $new_password = $_POST['new_pass'];
     if (!$old_password) {
         /**
          * Return error if current password is empty value
          */
         $this->setError('E103');
         return null;
     }
     /**
      * Update password to database
      */
     $status = JS_User::updateProfileInformation(array('ID' => $this->user->ID, 'user_pass' => $new_password, 'edit_task' => 'change_password'));
     if ($status === -2) {
         /**
          * Return errors if password is not changed.
          */
         $this->setError('E102');
         return null;
     } else {
         /**
          * Change password successful
          */
         $this->setSuccess('Your password is changed');
         return 1;
     }
 }
示例#2
0
 function ajax_update_profile()
 {
     echo JS_User::updateProfileInformation($_POST);
     exit;
 }