Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
MaarchParapheur
Manage
Activity
Members
Plan
Redmine
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Maarch
MaarchParapheur
Commits
8f93087a
Commit
8f93087a
authored
3 years ago
by
Quentin Ribac
Browse files
Options
Downloads
Patches
Plain Diff
FEAT #17436 TIME 0:13 unlink a user from a group with correct privileges
parent
f1a23203
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/app/group/controllers/GroupController.php
+15
-1
15 additions, 1 deletion
src/app/group/controllers/GroupController.php
with
15 additions
and
1 deletion
src/app/group/controllers/GroupController.php
+
15
−
1
View file @
8f93087a
...
...
@@ -20,6 +20,7 @@ use History\controllers\HistoryController;
use
Respect\Validation\Validator
;
use
Slim\Http\Request
;
use
Slim\Http\Response
;
use
User\controllers\UserController
;
use
User\models\UserGroupModel
;
use
User\models\UserModel
;
...
...
@@ -313,7 +314,20 @@ class GroupController
public
function
removeUser
(
Request
$request
,
Response
$response
,
array
$aArgs
)
{
if
(
!
PrivilegeController
::
hasPrivilege
([
'userId'
=>
$GLOBALS
[
'id'
],
'privilege'
=>
'manage_groups'
])
&&
!
PrivilegeController
::
hasPrivilege
([
'userId'
=>
$GLOBALS
[
'id'
],
'privilege'
=>
'manage_users'
]))
{
$hasGroupPrivilege
=
PrivilegeController
::
hasPrivilege
([
'userId'
=>
$GLOBALS
[
'id'
],
'privilege'
=>
'manage_groups'
]);
$hasUserPrivilege
=
false
;
$manageableGroups
=
UserController
::
getManageableGroups
([
'userId'
=>
$GLOBALS
[
'id'
]]);
$targetUserGroups
=
UserGroupModel
::
get
([
'select'
=>
[
'group_id'
],
'where'
=>
[
'user_id = ?'
],
'data'
=>
[
$aArgs
[
'userId'
]]
]);
$targetUserGroups
=
array_column
(
$targetUserGroups
,
'group_id'
);
if
(
!
empty
(
array_intersect
(
$manageableGroups
,
$targetUserGroups
)))
{
$hasUserPrivilege
=
true
;
}
if
(
!
$hasGroupPrivilege
&&
!
$hasUserPrivilege
)
{
return
$response
->
withStatus
(
403
)
->
withJson
([
'errors'
=>
'Privilege forbidden'
]);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment