
&^c           @   sD   d  d l  m Z d  d l Td  d l m Z d e f d     YZ d S(   i(   t   User(   t   *t   customAuthentificationc           B   s&   e  Z d  Z d d d  Z d   Z RS(   sF   
    Use the login name and a hash of the password. For example:

    c         C   s   d | | f GH| r yL t  j j d |  } t   } t j | | | j  rW d GH| Sd GHd  SWn t  j k
 r| d GHn Xd  Sd  S(   Ns7   ======= on essaye custom authentification avec %s et %st   usernames   PASSWORD OKs   PASSWORD KOs   User not exists(   R    t   objectst   gett   SHA256PasswordHashert   verifyt   passwordt   Nonet   DoesNotExist(   t   selfR   R   t   usert   encoder(    (    s<   /var/www/agenderbackend/backoffice/customAuthentification.pyt   authenticate   s    		c         C   s3   y t  j j d |  SWn t  j k
 r. d  SXd  S(   Nt   pk(   R    R   R   R
   R	   (   R   t   user_id(    (    s<   /var/www/agenderbackend/backoffice/customAuthentification.pyt   get_user   s    N(   t   __name__t
   __module__t   __doc__R	   R   R   (    (    (    s<   /var/www/agenderbackend/backoffice/customAuthentification.pyR      s   N(   t   django.contrib.auth.modelsR    t   libs.hasherst   modelst   objectR   (    (    (    s<   /var/www/agenderbackend/backoffice/customAuthentification.pyt   <module>   s   
