Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
rng-3202298
Manage
Activity
Members
Labels
Plan
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Issue forks
rng-3202298
Commits
7e14fe34
Commit
7e14fe34
authored
8 years ago
by
dpi
Browse files
Options
Downloads
Patches
Plain Diff
Refactoring registration access control handler and fixing access bugs since
030ca165
.
parent
bb443689
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/AccessControl/RegistrationAccessControlHandler.php
+18
-11
18 additions, 11 deletions
src/AccessControl/RegistrationAccessControlHandler.php
with
18 additions
and
11 deletions
src/AccessControl/RegistrationAccessControlHandler.php
+
18
−
11
View file @
7e14fe34
...
@@ -86,44 +86,51 @@ class RegistrationAccessControlHandler extends EntityAccessControlHandler {
...
@@ -86,44 +86,51 @@ class RegistrationAccessControlHandler extends EntityAccessControlHandler {
throw
new
AccessException
(
'Requires event context.'
);
throw
new
AccessException
(
'Requires event context.'
);
}
}
$event
=
$context
[
'event'
];
$fail
=
$return_as_object
?
AccessResult
::
forbidden
()
->
addCacheableDependency
(
$event
)
:
FALSE
;
$account
=
$this
->
prepareUser
(
$account
);
$account
=
$this
->
prepareUser
(
$account
);
if
(
$account
->
isAnonymous
())
{
if
(
$account
->
isAnonymous
())
{
return
AccessResult
::
neutral
();
return
AccessResult
::
neutral
();
}
}
try
{
try
{
$event_meta
=
$this
->
eventManager
->
getMeta
(
$
context
[
'
event
'
]
);
$event_meta
=
$this
->
eventManager
->
getMeta
(
$event
);
// $entity_bundle is omitted for registration type list at
// $entity_bundle is omitted for registration type list at
// $event_path/register
// $event_path/register
if
(
$entity_bundle
&&
$registration_type
=
RegistrationType
::
load
(
$entity_bundle
))
{
if
(
$entity_bundle
&&
(
$registration_type
=
RegistrationType
::
load
(
$entity_bundle
))
)
{
if
(
!
$event_meta
->
registrationTypeIsValid
(
$registration_type
))
{
if
(
!
$event_meta
->
registrationTypeIsValid
(
$registration_type
))
{
return
AccessResult
::
neutral
()
;
return
$fail
;
}
}
}
}
// There are no registration types configured.
// There are no registration types configured.
elseif
(
!
$event_meta
->
getRegistrationTypeIds
())
{
elseif
(
!
$event_meta
->
getRegistrationTypeIds
())
{
return
AccessResult
::
neutral
()
;
return
$fail
;
}
}
if
(
!
$event_meta
->
isAcceptingRegistrations
())
{
if
(
!
$event_meta
->
isAcceptingRegistrations
())
{
return
AccessResult
::
neutral
()
;
return
$fail
;
}
}
if
(
$event_meta
->
remainingCapacity
()
==
0
)
{
if
(
$event_meta
->
remainingCapacity
()
==
0
)
{
return
AccessResult
::
neutral
()
;
return
$fail
;
}
}
if
(
!
$event_meta
->
countProxyIdentities
())
{
if
(
!
$event_meta
->
countProxyIdentities
())
{
return
AccessResult
::
neutral
();
return
$fail
;
}
$result
=
parent
::
createAccess
(
$entity_bundle
,
$account
,
$context
,
TRUE
);
if
(
$result
->
isForbidden
())
{
return
$return_as_object
?
$result
:
$result
->
isAllowed
();
}
}
return
$return_as_object
?
AccessResult
::
allowed
()
:
TRUE
;
}
}
catch
(
InvalidEventException
$e
)
{
catch
(
InvalidEventException
$e
)
{
return
AccessResult
::
neutral
()
;
return
$fail
;
}
}
$result
=
parent
::
createAccess
(
$entity_bundle
,
$account
,
$context
,
TRUE
)
->
cachePerPermissions
();
return
$return_as_object
?
$result
:
$result
->
isAllowed
();
}
}
}
}
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