diff --git a/group_capabilities.php b/group_capabilities.php index e8850fe..17e30e8 100644 --- a/group_capabilities.php +++ b/group_capabilities.php @@ -1,12 +1,14 @@ 'create groups', - 'groups_can_edit' => 'edit group info', - 'groups_can_create_user' => 'create new users inside groups', - 'groups_can_add_member_auth' => 'add users to groups with their passwords', + 'groups_can_create' => 'create groups', + 'groups_can_edit' => 'edit group info', + 'groups_can_delete' => 'delete groups', + 'groups_can_create_user' => 'create new users inside groups', + 'groups_can_add_member_auth' => 'add users to groups (with password)', + 'groups_can_add_member_no_auth' => 'add users to groups (without password)', 'groups_can_add_member_invite' => 'invite users to join groups', - 'groups_can_delete' => 'delete groups', - 'groups_can_delete_user' => 'delete users', - 'groups_can_edit_user' => 'edit user info' + 'groups_can_delete_user' => 'delete users', + 'groups_can_edit_user' => 'edit user info', + 'groups_can_impersonate' => 'can impersonate other users', ]; diff --git a/group_model.php b/group_model.php index d433fef..f5da019 100644 --- a/group_model.php +++ b/group_model.php @@ -198,15 +198,20 @@ public function add_user_auth($admin_userid, $groupid, $username, $password, $ro return array('success' => false, 'message' => _("You haven't got enough permissions to add a member to this group")); } - // 2. Check username and password, return - $result = $this->user->get_apikeys_from_login($username, $password); - if (!$result["success"]) { - $this->log->error("Error adding user to group, username and password don't match - Session userid: " . $admin_userid); - return $result; + // 2. Check username and password if required + // We only allow adding without a password if the capabilities module is loaded + if (class_exists('Capabilities') && user_has_capability('groups_can_add_member_no_auth')) { + $add_userid = $this->user->get_id($username); + } else { + $result = $this->user->get_apikeys_from_login($username, $password); + if (!$result["success"]) { + $this->log->error("Error adding user to group, username and password don't match - Session userid: " . $admin_userid); + return $result; + } + $add_userid = $result["userid"]; } - $add_userid = $result["userid"]; - // 3. Add user to group + // 3. Add user to group if (!$this->add_user($groupid, $add_userid, $role)) { $this->log->error("Error adding user to group"); return array('success' => false, 'message' => _("Error adding user to group")); diff --git a/group_view.php b/group_view.php index 139d5bc..bc988a8 100644 --- a/group_view.php +++ b/group_view.php @@ -86,7 +86,8 @@ + user_has_capability('groups_can_add_member_auth') || + user_has_capability('groups_can_add_member_no_auth')) { ?> @@ -156,10 +157,15 @@

Username:

+ +

Password:

+ +

Role :