Conversation
| // Check subadmin has access to this group | ||
| if($this->groupManager->isAdmin($user->getUID()) | ||
| || $isSubadminOfGroup) { | ||
| $users = $this->groupManager->get($groupId)->getUsers(); |
There was a problem hiding this comment.
you already got the group in 210,
also here the null check is missing.
| $user = $this->userSession->getUser(); | ||
|
|
||
| // Check the group exists | ||
| if(!$this->groupManager->groupExists($groupId)) { |
There was a problem hiding this comment.
I suggest to get the group here and use the check for null to error out.
If you got a group don't check it any further
cac9609 to
0db5c79
Compare
Codecov Report
@@ Coverage Diff @@
## master #8904 +/- ##
===========================================
- Coverage 51.97% 51.87% -0.1%
+ Complexity 25287 25285 -2
===========================================
Files 1601 1602 +1
Lines 94984 94996 +12
Branches 1388 1388
===========================================
- Hits 49366 49283 -83
- Misses 45618 45713 +95
|
0db5c79 to
e92f640
Compare
|
Ready for review again. |
| // Users | ||
| ['root' => '/cloud', 'name' => 'Users#getUsers', 'url' => '/users', 'verb' => 'GET'], | ||
| ['root' => '/cloud', 'name' => 'Users#getUsersDetails', 'url' => '/users/details', 'verb' => 'GET'], | ||
| ['root' => '/cloud', 'name' => 'Users#getUsersGroupDetails', 'url' => '/users/{groupId}/details', 'verb' => 'GET'], |
There was a problem hiding this comment.
The route doesn't really fit the schema of the others. Maybe something like /groups/{groupId}/users would make more sense.
There was a problem hiding this comment.
I asked myself the same question, and was rather confuse, do we extract tehe users by groups or do we get the users in group :)
Therefore my current choice, especially since the getUsersData function is in the UsersController :)
There was a problem hiding this comment.
And since /groups/{groupId}/ actually return the users, shouldn't we go for something like /groups/{groupId}/details? It really lokks like groups-informations related data. I would prefer something like /groups/{groupId}/users/details but /groups/{groupId}/users doesn't exists :/
There was a problem hiding this comment.
/groups/{groupId}/details sounds good to me.
There was a problem hiding this comment.
Such url is supposed to return the details of the group, like we have in /groups/details :)
There was a problem hiding this comment.
I had teh same weird feeling on the url,
it doesn't feel right to me, maybe a ?group=<filter> on the current endpoint is the better option?
| $isSubadminOfGroup = false; | ||
| $group = $this->groupManager->get($groupId); | ||
| if ($group !== null) { | ||
| $isSubadminOfGroup = $this->groupManager->getSubAdmin()->isSubAdminofGroup($user, $group); |
There was a problem hiding this comment.
isSubAdminofGroup -> isSubAdminOfGroup
| if ($group !== null) { | ||
| $isSubadminOfGroup = $this->groupManager->getSubAdmin()->isSubAdminofGroup($user, $group); | ||
| } else { | ||
| throw new OCSException('The requested group could not be found', \OCP\API::RESPOND_NOT_FOUND); |
There was a problem hiding this comment.
\OCP\API is deprecated, see OCSNotFoundException
| }, $users); | ||
| $users = array_slice(array_values($users), $offset, $limit); | ||
| } else { | ||
| throw new OCSException('User does not have access to specified group', \OCP\API::RESPOND_UNAUTHORISED); |
There was a problem hiding this comment.
\OCP\API is deprecated, see OCSForbiddenException
f428a0b to
d473653
Compare
|
Ready for reviews again! :) $.get(OC.linkToOCS('cloud/groups/admin/users',2)+'details').then((response)=>console.log(response))
$.get(OC.linkToOCS('cloud/groups/admin/users',2)+'details?limit=10').then((response)=>console.log(response))
$.get(OC.linkToOCS('cloud/groups/admin/users',2)+'details?limit=2&offset=2').then((response)=>console.log(response)) |
| ['root' => '/cloud', 'name' => 'Groups#getGroups', 'url' => '/groups', 'verb' => 'GET'], | ||
| ['root' => '/cloud', 'name' => 'Groups#getGroupsDetails', 'url' => '/groups/details', 'verb' => 'GET'], | ||
| ['root' => '/cloud', 'name' => 'Groups#getGroup', 'url' => '/groups/{groupId}', 'verb' => 'GET'], | ||
| ['root' => '/cloud', 'name' => 'Groups#getGroupUsers', 'url' => '/groups/{groupId}/users', 'verb' => 'GET'], |
There was a problem hiding this comment.
Fallback to proper url design, above one is deprecated!
There was a problem hiding this comment.
Could you add a note about this to #7827? But I guess it's not easily possible to drop this as it is part of the OCS standard 😉
| IUserSession $userSession, | ||
| ILogger $logger) { | ||
| ILogger $logger, | ||
| UsersController $userController) { |
There was a problem hiding this comment.
Instead extract the shared logic in a subclass/trait?
There was a problem hiding this comment.
@nickvergessen what would you suggest to have a clean logic?
| use OCP\IRequest; | ||
| use OCP\IUserSession; | ||
| use OCP\IUser; | ||
| use OCA\Provisioning_API\Controller\UsersController; |
There was a problem hiding this comment.
this should not be needed
| $offset = (int)$offset; | ||
| } | ||
|
|
||
| public function getGroupsDetails(string $search = '', int $limit = null, int $offset = 0): DataResponse { |
There was a problem hiding this comment.
limit is not checked for null anymore?
There was a problem hiding this comment.
Since we use slice to cut our arrays, null will be ignored. :)
array array_slice ( array $array , int $offset [, int $length = NULL [, bool $preserve_keys = FALSE ]] )
https://secure.php.net/manual/en/function.array-slice.php
4b4f4dc to
9b081c8
Compare
| * @throws OCSException | ||
| */ | ||
| public function getUserData(string $userId): array { | ||
| $currentLoggedInUser = $this->userSession->getUser(); |
There was a problem hiding this comment.
Hmm php storm doesn't know userSession. I guess you need to declare it in this trait too.
1663ec5 to
5d13464
Compare
|
Bump, failure unrelated (swift) :) |
| * @return DataResponse | ||
| * @throws OCSException | ||
| * | ||
| * @deprecated 14 Use getGroupUsers |
There was a problem hiding this comment.
Could you add a note about this to #7827? But I guess it's not easily possible to drop this as it is part of the OCS standard 😉
There was a problem hiding this comment.
Yeah, I thought it was the better way. It's not that bad tough :)
|
CONFLICTS!!! |
Signed-off-by: John Molakvoæ (skjnldsv) <[email protected]>
Signed-off-by: John Molakvoæ (skjnldsv) <[email protected]>
Signed-off-by: John Molakvoæ (skjnldsv) <[email protected]>
Signed-off-by: John Molakvoæ (skjnldsv) <[email protected]>
Signed-off-by: John Molakvoæ (skjnldsv) <[email protected]>
Signed-off-by: John Molakvoæ (skjnldsv) <[email protected]>
Signed-off-by: Joas Schilling <[email protected]>
Signed-off-by: John Molakvoæ (skjnldsv) <[email protected]>
5d13464 to
eb4d7fb
Compare
|
Failure unrelated: swift :) |
This allows to get the users detailed data directly by requesting the groupid