ó
®â0_c           @  sì   d  Z  d d l m Z d d l Z d d l m Z d d l m Z m Z m	 Z	 d d l
 m Z d d l m Z m Z d d l m Z m Z d d	 l m Z m Z d d
 l m Z d e j f d „  ƒ  YZ e d e j f d „  ƒ  Yƒ Z d S(   ug   
This module allows importing AbstractBaseUser even when django.contrib.auth is
not in INSTALLED_APPS.
iÿÿÿÿ(   t   unicode_literalsN(   t   password_validation(   t   check_passwordt   is_password_usablet   make_password(   t   models(   t   get_random_stringt   salted_hmac(   t   CallableFalset   CallableTrue(   t
   force_textt   python_2_unicode_compatible(   t   ugettext_lazyt   BaseUserManagerc           B  s/   e  Z e d  „  ƒ Z d d d „ Z d „  Z RS(   c         C  sa   | p	 d } y" | j  ƒ  j d d ƒ \ } } Wn t k
 rA n Xd j | | j ƒ  g ƒ } | S(   uS   
        Normalize the email address by lowercasing the domain part of it.
        u    u   @i   (   t   stript   rsplitt
   ValueErrort   joint   lower(   t   clst   emailt
   email_namet   domain_part(    (    s?   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/auth/base_user.pyt   normalize_email   s    "i
   u7   abcdefghjkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789c         C  s   t  | | ƒ S(   uë   
        Generate a random password with the given length and given
        allowed_chars. The default value of allowed_chars does not have "I" or
        "O" or letters and digits that look similar -- just to avoid confusion.
        (   R   (   t   selft   lengtht   allowed_chars(    (    s?   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/auth/base_user.pyt   make_random_password$   s    	c         C  s   |  j  i | |  j j 6  S(   N(   t   gett   modelt   USERNAME_FIELD(   R   t   username(    (    s?   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/auth/base_user.pyt   get_by_natural_key/   s    (   t   __name__t
   __module__t   classmethodR   R   R    (    (    (    s?   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/auth/base_user.pyR      s   
t   AbstractBaseUserc           B  s  e  Z e j e d  ƒ d d ƒZ e j e d ƒ d e d e ƒZ e Z	 g  Z
 d d d „  ƒ  YZ d „  Z d	 „  Z d
 „  Z d „  Z d „  Z d „  Z e d „  ƒ Z e d „  ƒ Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z e d „  ƒ Z e d „  ƒ Z RS(   u   passwordt
   max_lengthi€   u
   last logint   blankt   nullt   Metac           B  s   e  Z e Z RS(    (   R!   R"   t   Truet   abstract(    (    (    s?   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/auth/base_user.pyR(   <   s   c         C  s   t  |  |  j ƒ S(   u-   Return the identifying username for this User(   t   getattrR   (   R   (    (    s?   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/auth/base_user.pyt   get_username?   s    c         O  s&   t  t |  ƒ j | | Ž  d  |  _ d  S(   N(   t   superR$   t   __init__t   Nonet	   _password(   R   t   argst   kwargs(    (    s?   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/auth/base_user.pyR.   C   s    c         C  s
   |  j  ƒ  S(   N(   R,   (   R   (    (    s?   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/auth/base_user.pyt   __str__I   s    c         C  s&   t  |  |  j |  j |  j ƒ  ƒ ƒ d  S(   N(   t   setattrR   t   normalize_usernameR,   (   R   (    (    s?   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/auth/base_user.pyt   cleanL   s    c         O  sK   t  t |  ƒ j | | Ž  |  j d  k	 rG t j |  j |  ƒ d  |  _ n  d  S(   N(   R-   R$   t   saveR0   R/   R   t   password_changed(   R   R1   R2   (    (    s?   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/auth/base_user.pyR7   O   s    c         C  s   |  j  ƒ  f S(   N(   R,   (   R   (    (    s?   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/auth/base_user.pyt   natural_keyU   s    c         C  s   t  S(   uj   
        Always return False. This is a way of comparing User objects to
        anonymous users.
        (   R   (   R   (    (    s?   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/auth/base_user.pyt   is_anonymousX   s    c         C  s   t  S(   ut   
        Always return True. This is a way to tell if the user has been
        authenticated in templates.
        (   R	   (   R   (    (    s?   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/auth/base_user.pyt   is_authenticated`   s    c         C  s   t  | ƒ |  _ | |  _ d  S(   N(   R   t   passwordR0   (   R   t   raw_password(    (    s?   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/auth/base_user.pyt   set_passwordh   s    c           s"   ‡  f d †  } t  | ˆ  j | ƒ S(   u~   
        Return a boolean of whether the raw_password was correct. Handles
        hashing formats behind the scenes.
        c           s-   ˆ  j  |  ƒ d  ˆ  _ ˆ  j d d g ƒ d  S(   Nt   update_fieldsu   password(   R>   R/   R0   R7   (   R=   (   R   (    s?   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/auth/base_user.pyt   setterq   s    	(   R   R<   (   R   R=   R@   (    (   R   s?   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/auth/base_user.pyR   l   s    c         C  s   t  d  ƒ |  _ d  S(   N(   R   R/   R<   (   R   (    (    s?   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/auth/base_user.pyt   set_unusable_passwordx   s    c         C  s   t  |  j ƒ S(   N(   R   R<   (   R   (    (    s?   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/auth/base_user.pyt   has_usable_password|   s    c         C  s   t  d ƒ ‚ d  S(   NuD   subclasses of AbstractBaseUser must provide a get_full_name() method(   t   NotImplementedError(   R   (    (    s?   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/auth/base_user.pyt   get_full_name   s    c         C  s   t  d ƒ ‚ d  S(   NuF   subclasses of AbstractBaseUser must provide a get_short_name() method.(   RC   (   R   (    (    s?   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/auth/base_user.pyt   get_short_name‚   s    c         C  s   d } t  | |  j ƒ j ƒ  S(   u7   
        Return an HMAC of the password field.
        uA   django.contrib.auth.models.AbstractBaseUser.get_session_auth_hash(   R   R<   t	   hexdigest(   R   t   key_salt(    (    s?   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/auth/base_user.pyt   get_session_auth_hash…   s    c         C  s$   y |  j  SWn t k
 r d SXd  S(   Nu   email(   t   EMAIL_FIELDt   AttributeError(   R   (    (    s?   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/auth/base_user.pyt   get_email_field_nameŒ   s    c         C  s   t  j d t | ƒ ƒ S(   Nu   NFKC(   t   unicodedatat	   normalizeR
   (   R   R   (    (    s?   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/auth/base_user.pyR5   “   s    (    (   R!   R"   R   t	   CharFieldt   _R<   t   DateTimeFieldR)   t
   last_logint	   is_activet   REQUIRED_FIELDSR(   R,   R.   R3   R6   R7   R9   t   propertyR:   R;   R>   R   RA   RB   RD   RE   RH   R#   RK   R5   (    (    (    s?   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/auth/base_user.pyR$   3   s,   !													(   t   __doc__t
   __future__R    RL   t   django.contrib.authR   t   django.contrib.auth.hashersR   R   R   t	   django.dbR   t   django.utils.cryptoR   R   t   django.utils.deprecationR   R	   t   django.utils.encodingR
   R   t   django.utils.translationR   RO   t   ManagerR   t   ModelR$   (    (    (    s?   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/auth/base_user.pyt   <module>   s   