fix permission checks for command forms
This commit is contained in:
@@ -260,14 +260,19 @@ async def process_field_edit_callback(message: Message | CallbackQuery, **kwargs
|
|||||||
|
|
||||||
# What if user has several roles and each role has its own ownership field? Should we allow creation even
|
# What if user has several roles and each role has its own ownership field? Should we allow creation even
|
||||||
# if user has no CREATE_ALL permission
|
# if user has no CREATE_ALL permission
|
||||||
user_permissions = get_user_permissions(user, entity_descriptor)
|
|
||||||
|
|
||||||
for role in user.roles:
|
if callback_data.context in [
|
||||||
if (
|
CommandContext.ENTITY_CREATE,
|
||||||
role in entity_descriptor.ownership_fields
|
CommandContext.ENTITY_EDIT,
|
||||||
and EntityPermission.CREATE_ALL not in user_permissions
|
]:
|
||||||
):
|
user_permissions = get_user_permissions(user, entity_descriptor)
|
||||||
entity_data[entity_descriptor.ownership_fields[role]] = user.id
|
|
||||||
|
for role in user.roles:
|
||||||
|
if (
|
||||||
|
role in entity_descriptor.ownership_fields
|
||||||
|
and EntityPermission.CREATE_ALL not in user_permissions
|
||||||
|
):
|
||||||
|
entity_data[entity_descriptor.ownership_fields[role]] = user.id
|
||||||
|
|
||||||
deser_entity_data = {
|
deser_entity_data = {
|
||||||
key: await deserialize(
|
key: await deserialize(
|
||||||
|
|||||||
Reference in New Issue
Block a user