Files
depot_django/accounts/backends.py
T
gitea daba5a8438 Add IntelliJ IDEA project configuration files
This commit adds IntelliJ IDEA-specific configuration files for the project, including module setup, version control integration, inspection profiles, and workspace settings. These files facilitate development environment configuration for contributors using IntelliJ IDEA.
2025-06-30 18:06:35 +03:00

16 lines
616 B
Python

from django.contrib.auth.backends import ModelBackend
class CompanyUserBackend(ModelBackend):
def get_user_permissions(self, user_obj, obj=None):
if not user_obj.is_active or user_obj.is_anonymous:
return set()
if user_obj.is_superuser:
return super().get_user_permissions(user_obj, obj)
perms = super().get_user_permissions(user_obj, obj)
if user_obj.company and user_obj.company.is_client:
# Filter permissions based on client company context
perms = {p for p in perms if p.startswith('accounts.client_')}
return perms