Ticket #18038: 18038-wip.patch

File 18038-wip.patch, 3.4 KB (added by Aymeric Augustin, 12 years ago)
  • docs/topics/auth.txt

     
    18401840        ADMIN_PASSWORD = 'sha1$4e987$afbcf42e21bd417fb71db8c66b321e9fc33051de'
    18411841        """
    18421842
    1843         supports_inactive_user = False
    1844 
    18451843        def authenticate(self, username=None, password=None):
    18461844            login_valid = (settings.ADMIN_LOGIN == username)
    18471845            pwd_valid = check_password(password, settings.ADMIN_PASSWORD)
     
    19401938anonymous users to have permissions to do something while inactive
    19411939authenticated users do not.
    19421940
    1943 To enable this on your own backend, you must set the class attribute
    1944 ``supports_inactive_user`` to ``True``.
    19451941
    1946 A nonexisting ``supports_inactive_user`` attribute will raise a
    1947 ``PendingDeprecationWarning`` if used in Django 1.3. In Django 1.4, this
    1948 warning will be updated to a ``DeprecationWarning`` which will be displayed
    1949 loudly. Additionally ``supports_inactive_user`` will be set to ``False``.
    1950 Django 1.5 will assume that every backend supports inactive users being
    1951 passed to the authorization methods.
    1952 
    1953 
    19541942Handling object permissions
    19551943---------------------------
    19561944
  • django/contrib/auth/__init__.py

     
    1 from warnings import warn
    21from django.core.exceptions import ImproperlyConfigured
    32from django.utils.importlib import import_module
    43from django.contrib.auth.signals import user_logged_in, user_logged_out
     
    2120    except AttributeError:
    2221        raise ImproperlyConfigured('Module "%s" does not define a "%s" authentication backend' % (module, attr))
    2322
    24     if not hasattr(cls, 'supports_inactive_user'):
    25         warn("Authentication backends without a `supports_inactive_user` attribute are deprecated. Please define it in %s." % cls,
    26              DeprecationWarning)
    27         cls.supports_inactive_user = False
    2823    return cls()
    2924
    3025def get_backends():
  • django/contrib/auth/backends.py

     
    55    """
    66    Authenticates against django.contrib.auth.models.User.
    77    """
    8     supports_inactive_user = True
    98
    109    # TODO: Model, login attribute name and password attribute name should be
    1110    # configurable.
  • django/contrib/auth/models.py

     
    200200    anon = user.is_anonymous()
    201201    active = user.is_active
    202202    for backend in auth.get_backends():
    203         if anon or active or backend.supports_inactive_user:
     203        if anon or active:
    204204            if hasattr(backend, "has_perm"):
    205205                if obj is not None:
    206206                    if backend.has_perm(user, perm, obj):
     
    215215    anon = user.is_anonymous()
    216216    active = user.is_active
    217217    for backend in auth.get_backends():
    218         if anon or active or backend.supports_inactive_user:
     218        if anon or active:
    219219            if hasattr(backend, "has_module_perms"):
    220220                if backend.has_module_perms(user, app_label):
    221221                    return True
Back to Top