summaryrefslogtreecommitdiffstats
path: root/lib/api/kolab_api_service_user.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/api/kolab_api_service_user.php')
-rw-r--r--lib/api/kolab_api_service_user.php59
1 files changed, 47 insertions, 12 deletions
diff --git a/lib/api/kolab_api_service_user.php b/lib/api/kolab_api_service_user.php
index 43ab530..d63636d 100644
--- a/lib/api/kolab_api_service_user.php
+++ b/lib/api/kolab_api_service_user.php
@@ -37,14 +37,10 @@ class kolab_api_service_user extends kolab_api_service
*/
public function capabilities($domain)
{
- //console("kolab_api_service_group::capabilities");
-
$auth = Auth::get_instance($domain);
$effective_rights = $auth->list_rights('user');
- //console("effective_rights", $effective_rights);
-
$rights = array();
if (in_array('add', $effective_rights['entryLevelRights'])) {
@@ -56,7 +52,8 @@ class kolab_api_service_user extends kolab_api_service
}
if (in_array('modrdn', $effective_rights['entryLevelRights'])) {
- $rights['edit'] = "w";
+ $rights['edit'] = "w";
+ $rights['password'] = "w";
}
if (in_array('read', $effective_rights['entryLevelRights'])) {
@@ -111,7 +108,6 @@ class kolab_api_service_user extends kolab_api_service
*/
public function user_delete($getdata, $postdata)
{
- //console("user_delete()", $getdata, $postdata);
if (!isset($postdata['id'])) {
return false;
}
@@ -120,13 +116,17 @@ class kolab_api_service_user extends kolab_api_service
$auth = Auth::get_instance();
$result = $auth->user_delete($postdata['id']);
- if ($result) {
- return $result;
- }
-
- return false;
+ return $result;
}
+ /**
+ * Update user.
+ *
+ * @param array $get GET parameters
+ * @param array $post POST parameters
+ *
+ * @return array|bool User attributes or False on error.
+ */
public function user_edit($getdata, $postdata)
{
Log::trace("\$postdata to user_edit()", $postdata);
@@ -148,9 +148,45 @@ class kolab_api_service_user extends kolab_api_service
}
return false;
+ }
+ /**
+ * Update user password.
+ *
+ * @param array $get GET parameters
+ * @param array $post POST parameters
+ *
+ * @return bool True on success, False on failure
+ */
+ public function user_password($getdata, $postdata)
+ {
+ $password = $postdata['password'];
+ $user_id = $postdata['id'];
+
+ if (empty($user_id) || !is_string($password) || !strlen($password)) {
+ return false;
+ }
+
+ if ($user_id === 'me') {
+ $user_id = $_SESSION['user']->get_userid();
+ }
+
+ password_policy::validate_password($password);
+
+ $auth = Auth::get_instance();
+ $result = $auth->user_edit($user_id, array('userpassword' => $password));
+
+ return $result !== false;
}
+ /**
+ * Effective rights on user record.
+ *
+ * @param array $get GET parameters
+ * @param array $post POST parameters
+ *
+ * @return array Effective rights
+ */
public function user_effective_rights($getdata, $postdata)
{
$auth = Auth::get_instance();
@@ -230,5 +266,4 @@ class kolab_api_service_user extends kolab_api_service
return false;
}
-
}