*
* Updating the password will modify the $user object and the database
* record to use the current hashing algorithm.
+ * It will remove Web Services user tokens too.
*
* @param stdClass $user User object (password property may be updated).
* @param string $password Plain text password.
// Trigger event.
$user = $DB->get_record('user', array('id' => $user->id));
\core\event\user_password_updated::create_from_user($user)->trigger();
+
+ // Remove WS user tokens.
+ require_once($CFG->dirroot.'/webservice/lib.php');
+ webservice::delete_user_ws_tokens($user->id);
}
return true;
$DB->delete_records('external_tokens', array('id'=>$tokenid));
}
+ /**
+ * Delete all the tokens belonging to a user.
+ *
+ * @param int $userid the user id whose tokens must be deleted
+ */
+ public static function delete_user_ws_tokens($userid) {
+ global $DB;
+ $DB->delete_records('external_tokens', array('userid' => $userid));
+ }
+
/**
* Delete a service
* Also delete function references and authorised user references.