Skip to content

Commit

Permalink
fix: Исправил ошибку при проверке анон пользователя.
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonVagabond committed Mar 7, 2024
1 parent 8053107 commit eca09be
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions orders/permissions/orders.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ def has_object_permission(
Проверка пользователя на доступ к конкретному заказу.
Если это персонал, то доступ на изменение товара разрешит.
"""
if request.user.is_anonymous:
return False
if request.user.is_staff or request.user.is_superuser:
return True
if request.user == obj.user:
Expand Down
2 changes: 1 addition & 1 deletion products/permissions/categories.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def has_permission(self, request: Request, view: CategoryView) -> bool:
"""
if request.method in SAFE_METHODS:
return True
if request.user.is_anonymous():
if request.user.is_anonymous:
return False
return bool(
request.user.is_authenticated and
Expand Down
2 changes: 2 additions & 0 deletions products/permissions/providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ def has_object_permission(
Проверка пользователя на доступ к конкретному Поставщику.
Если это персонал, то доступ на изменение модели Поставщика разрешит.
"""
if not request.user.is_authenticated and request.user.is_anonymous:
return False
if request.user.is_staff or request.user.is_superuser:
return True
if request.user == obj.user:
Expand Down

0 comments on commit eca09be

Please sign in to comment.