0

I'm using services module, I want to modify (update) password on users table.

This is the resource definition.

'client_modification_mdp' => array(
  'operations' => array(
    'update' => array(
      'help' => 'Client souhaite modifier son propre mot de passe',
      'file' => array('type' => 'inc', 'module' => 'my_module', 'name' => 'my_module.resource'),
      'callback' => 'my_module_password_update',
      'access arguments' => array('clientPassword resource update'),
      'access arguments append' => FALSE,
      'args' => array(
        array(
          'name' => 'uid',
          'type' => 'int',
          'description' => 'id du client qui modifie son mot de passe',
          'source' => array('param' => 'uid'),
          'optional' => FALSE,
        ),
        array(
          'name' => 'password',
          'type' => 'string',
          'description' => 'password actuel du client',
          'source' => array('data'=>'password'),
          'optional' => FALSE,
        ),
        array(
          'name' => 'new_password',
          'type' => 'string',
          'description' => 'nouveau password du client',
          'source' => array('data'=>'new_password'),
          'optional' => FALSE,
        ),
      ),
    ),

This is the callback for that resource.

function my_module_password_update($uid, $password, $new_password) {
  $user = user_load($uid);
  $username = $user->name;
  $authentication = user_authenticate($username, $password);

  if ($authentication == true) {
    $update_psd = db_update('users')
      ->fields(array(
        'pass'=>$data["new_password"],
      ))
      ->condition("uid", $uid, '=')
      ->execute();
   }
 }

I'm sure there are some errors in the callback, but Postman returns the following error.

404 Not found: Could not find the controller.

I'm executing a PUT method.

Did anyone can help me to fix this issue please? Thank you

  • in callback function you need to use "_" first and then your function name. e.g. "_my_module_password_update". – vgoradiya Aug 24 '15 at 13:10
  • Could you, for the sake of this question, translate texts inside code to English? And by the way, the error message shows that your issue has nothing to do with user passwords, and everything with configuring services and setting up controller, Consider rephrasing your question and removing parts that are not needed at the moment. – Mołot Aug 24 '15 at 14:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.