예제 #1
0
    def has_perm(self, perm, obj=None):
        #     "Does the user have a specific permission?"
        # Simplest possible answer: Yes, always

        if self.is_active and self.is_superuser:
            return True
        return _user_has_perm(self, perm, obj)
예제 #2
0
    def has_perm(self, perm, obj=None):
        # Active superusers have all permissions.
        if self.is_active and self.is_admin:
            return True

        # Otherwise we need to check the backends.
        return _user_has_perm(self, perm, obj)
예제 #3
0
    def has_perm(self, perm, obj=None):
        # Active superusers have all permissions.
        if self.is_active and self.is_superuser:
            return True

        # Otherwise we need to check the backends.
        return _user_has_perm(self, perm, obj)
 def has_perm(self, perm, obj=None):
     """
     :param perm:
     :param obj:
     :return:
     """
     return _user_has_perm(self, perm, obj)
예제 #5
0
 def _check_perm(self, perm, obj):
     
     if not getattr(settings, 'DJEM_UNIVERSAL_OLP', False):
         # Default behaviour: active superusers implicitly have ALL permissions
         if self.is_active and self.is_superuser:
             return True, 'Active superuser: Implicit permission'
         
         return _user_has_perm(self, perm, obj), None
     else:
         # "Universal OLP" behaviour: active superusers implicitly have all
         # permissions at the model level, but are subject to object-level
         # checks
         if not obj and self.is_active and self.is_superuser:
             return True, 'Active superuser: Implicit permission (model-level)'
         
         return _user_has_perm(self, perm, obj), None
예제 #6
0
    def has_perm(self, perm: Union[BasePermissionEnum, str], obj=None):  # type: ignore
        # This method is overridden to accept perm as BasePermissionEnum
        perm = perm.value if hasattr(perm, "value") else perm  # type: ignore

        # Active superusers have all permissions.
        if self.is_active and self.is_superuser and not self._effective_permissions:
            return True
        return _user_has_perm(self, perm, obj)
예제 #7
0
    def has_perm(self, perm, obj=None):
        from django.contrib.auth.models import _user_has_perm

        # Active superusers have all permissions.
        if self.is_active and self.is_superuser:
            return True

        # Otherwise we need to check the backends.
        return _user_has_perm(self, perm, obj)
예제 #8
0
 def has_perm(self, perm, obj=None):
     """
     Returns True if the user has the specified permission. This method
     queries all available auth backends, but returns immediately if any
     backend returns True. Thus, a user who has permission from a single
     auth backend is assumed to have permission in general. If an object is
     provided, permissions for this specific object are checked.
     """
     return _user_has_perm(self, perm, obj)
예제 #9
0
 def has_perm(self, perm, obj=None):
     "Does the user have a specific permission?"
     # Simplest possible answer: Yes, always
     # print('user perm:',perm)
     if not self.is_active:
         return False
     if self.is_admin:
         return True
     return _user_has_perm(self, perm, obj)
예제 #10
0
    def has_perm(self, perm, obj=None):
        '''
        Checks if the user has a specific permission
        '''
        # Active admins have all permissions
        if self.is_active and self.is_admin:
            return True

        # Otherwise we need to check the backends
        return _user_has_perm(self, perm, obj)
예제 #11
0
    def has_perm(self, perm, obj=None):
        """
        Checks whether a user has the given permission.

        :param perm: A string identifying the permission. See the backends module in this app for a complete list.
        :param obj: An optional object, the interpretation of which depends on the permission string.
        :return: True or False
        :raises: ``InvalidPermission`` if the given permission string is unknown, or if the optional ``obj`` is an
            unexpected type.
        """
        return _user_has_perm(self, perm, obj)
예제 #12
0
    def has_perm(self, perm, obj=None):
        """
        Override PermissionsMixin has_perm to deactivate is_superuser if
        authenticated through a token
        """

        # Active superusers have all permissions.
        if self.is_active and self.is_superuser and not hasattr(self, "token"):
            return True

        # Otherwise we need to check the backends.
        return _user_has_perm(self, perm, obj)
예제 #13
0
    def has_perm(self, perm, obj=None):
        """Return True if the reviewer has the specified permission. Query all
        available auth backends, but return immediately if any backend returns
        True. Thus, a reviewer who has permission from a single auth backend is
        assumed to have permission in general. If an object is provided, check
        permissions for that object.
        """
        # Active superusers have all permissions.
        if self.is_active and self.trusted:
            return True

        # Otherwise we need to check the backends.
        return auth_models._user_has_perm(self, perm, obj)
예제 #14
0
 def has_perm(self, perm, obj=None):
     """
     Returns True if the user has the specified permission. This method
     queries all available auth backends, but returns immediately if any
     backend returns True. Thus, a user who has permission from a single
     auth backend is assumed to have permission in general. If an object is
     provided, permissions for this specific object are checked.
     """
     # Active superusers have all permissions.
     if self.is_active and self.is_superuser:
         return True
     # Otherwise we need to check the backends.
     return auth._user_has_perm(self, perm, obj)
예제 #15
0
    def has_perm(self, perm, obj=None):
        """
        Returns True if the user has the specified permission. This method queries all available auth backends, but
        returns immediately if any backend returns True. Thus, a user who has permission from a single auth backend is
        assumed to have permission in general. If an object is provided, permissions for this specific object are
        checked.
        """
        # Active superusers have all permissions.
        if self.is_active and self.is_superuser:
            return True

        # Otherwise we need to check the backends.
        return _user_has_perm(self, perm, obj)
예제 #16
0
    def has_perm(self, perm, obj=None):
        """
        Returns True if the user has the specified permission. This method
        queries all available auth backends, but returns immediately if any
        backend returns True. Thus, a user who has permission from a single
        auth backend is assumed to have permission in general. If an object is
        provided, permissions for this specific object are checked.

        This differs from the default in that superusers, while still having
        every permission, will be allowed after the logic has executed. This
        helps with typos in permission strings.
        """
        has_perm = _user_has_perm(self, perm, obj)
        # Active superusers have all permissions.
        if self.is_active and self.is_superuser:
            return True
        else:
            return has_perm
예제 #17
0
파일: models.py 프로젝트: Evans-Notch/lnldb
    def has_perm(self, perm, obj=None):
        """
        Returns True if the user has the specified permission. This method
        queries all available auth backends, but returns immediately if any
        backend returns True. Thus, a user who has permission from a single
        auth backend is assumed to have permission in general. If an object is
        provided, permissions for this specific object are checked.

        This differs from the default in that superusers, while still having
        every permission, will be allowed after the logic has executed. This
        helps with typos in permission strings.
        """
        has_perm = _user_has_perm(self, perm, obj)
        # Active superusers have all permissions.
        if self.is_active and self.is_superuser:
            return True
        else:
            return has_perm
예제 #18
0
    def has_perm(self, perm, obj=None):
        if self.is_active and self.is_superuser:
            return True

        return _user_has_perm(self, perm, obj)
예제 #19
0
 def has_terra_perm(self, codename):
     return _user_has_perm(self, f'{self._meta.app_label}.{codename}', None)
예제 #20
0
 def user_has_perm(user, perm, obj):
     """
     A backend can raise `PermissionDenied` to short-circuit permission checking.
     """
     return _user_has_perm(user, perm, obj)
예제 #21
0
 def has_perm(self, perm, obj=None):
     if self.is_superuser and self.activo:
         return True
     return _user_has_perm(self, perm, obj=obj)
예제 #22
0
 def user_has_perm(self, perm, obj):
     return _user_has_perm(self, perm, obj)
예제 #23
0
파일: models.py 프로젝트: Uttah/syn_app
 def has_perm(self, perm, obj=None):
     # Не уволенные суперпользователи имеют весь доступ
     if not self.fired and self.is_superuser:
         return True
     return _user_has_perm(self, perm, obj)
예제 #24
0
 def has_perm(self, perm, obj=None):
     return auth_models._user_has_perm(self, perm, obj=obj)
 def has_perm(self, perm, obj=None):
     """Near complete coppy of the django.auth.contrib.models.User has_perm method."""
     return _user_has_perm(self, perm, None)
 def has_perm(self, perm, obj=None):
     """Near complete coppy of the django.auth.contrib.models.User has_perm method."""
     return _user_has_perm(self, perm, None)
예제 #27
0
파일: models.py 프로젝트: suesan/uknow
 def user_has_perm(user, perm, obj):
     """
     A backend can raise `PermissionDenied` to short-circuit permission checking.
     """
     return _user_has_perm(user, perm, obj)
예제 #28
0
파일: models.py 프로젝트: danjac/ownblock
 def has_perm(self, perm, obj=None):
     return _user_has_perm(self, perm, obj=obj)
예제 #29
0
 def user_has_perm(user, perm, obj):
     return _user_has_perm(user, perm, obj)
예제 #30
0
 def has_perm(self, perm, obj=None):
     return _user_has_perm(self, perm, obj=obj)
예제 #31
0
 def has_edit_perm(self, perm, obj=None):
     if self.pk == obj.pk:
         return True
     return auth_models._user_has_perm(self, perm, obj)
예제 #32
0
    def has_perm(self, perm, obj=None):
        if self.is_active and self.is_superuser:
            return True

        # Otherwise we need to check the backends.
        return _user_has_perm(self, perm, obj)
예제 #33
0
    def has_perm(self, perm, obj=None):
        if self.is_active and self.is_superuser:
            return True

        return auth_models._user_has_perm(self, perm, obj)