
    rh                     p    d dl mZmZmZmZ d dlmZ d dlm	Z	 d dl
mZ ddlmZ erddlmZ  G d d	      Zy
)    )TYPE_CHECKINGAnyOptionalUnion)models)EmptyManager)cached_property   )api_settings)Tokenc                   Z   e Zd ZdZdZ eej                        Z eej                        Z
d%dZdefdZedefd       Zedefd       Zedefd	       Zedefd
       Zedefd       ZdedefdZdedefdZdefdZd&dZd&dZdeddfdZdeddfdZedej                  fd       Zedej                  fd       Z d'de!e   de"fdZ#d'de!e   de"fdZ$d'dede!e   defdZ%d'de&e   de!e   defdZ'dedefdZ(edefd        Z)edefd!       Z*defd"Z+d#ede!e,   fd$Z-y)(	TokenUsera  
    A dummy user class modeled after django.contrib.auth.models.AnonymousUser.
    Used in conjunction with the `JWTStatelessUserAuthentication` backend to
    implement single sign-on functionality across services which share the same
    secret key.  `JWTStatelessUserAuthentication` will return an instance of this
    class instead of a `User` model instance.  Instances of this class act as
    stateless user objects which are backed by validated tokens.
    TreturnNc                     || _         y N)token)selfr   s     r/var/www/html/ai-insurance-compliance-backend/venv/lib/python3.12/site-packages/rest_framework_simplejwt/models.py__init__zTokenUser.__init__   s	    
    c                      d| j                    S )Nz
TokenUser idr   s    r   __str__zTokenUser.__str__!   s    DGG9%%r   c                 <    | j                   t        j                     S r   )r   r   USER_ID_CLAIMr   s    r   r   zTokenUser.id$   s    zz,4455r   c                     | j                   S r   r   r   s    r   pkzTokenUser.pk(   s    wwr   c                 :    | j                   j                  dd      S )Nusername r   getr   s    r   r!   zTokenUser.username,   s    zz~~j"--r   c                 :    | j                   j                  dd      S )Nis_staffFr#   r   s    r   r&   zTokenUser.is_staff0   s    zz~~j%00r   c                 :    | j                   j                  dd      S )Nis_superuserFr#   r   s    r   r(   zTokenUser.is_superuser4   s    zz~~ne44r   otherc                 `    t        |t              st        S | j                  |j                  k(  S r   )
isinstancer   NotImplementedr   r   r)   s     r   __eq__zTokenUser.__eq__8   s%    %+!!ww%((""r   c                 &    | j                  |       S r   )r.   r-   s     r   __ne__zTokenUser.__ne__=   s    ;;u%%%r   c                 ,    t        | j                        S r   )hashr   r   s    r   __hash__zTokenUser.__hash__@   s    DGG}r   c                     t        d      Nz%Token users have no DB representationNotImplementedErrorr   s    r   savezTokenUser.saveC       !"IJJr   c                     t        d      r5   r6   r   s    r   deletezTokenUser.deleteF   r9   r   raw_passwordc                     t        d      r5   r6   r   r<   s     r   set_passwordzTokenUser.set_passwordI   r9   r   c                     t        d      r5   r6   r>   s     r   check_passwordzTokenUser.check_passwordL   r9   r   c                     | j                   S r   )_groupsr   s    r   groupszTokenUser.groupsO   s    ||r   c                     | j                   S r   )_user_permissionsr   s    r   user_permissionszTokenUser.user_permissionsS   s    %%%r   objc                     t               S r   setr   rH   s     r   get_group_permissionszTokenUser.get_group_permissionsW   	    ur   c                     t               S r   rJ   rL   s     r   get_all_permissionszTokenUser.get_all_permissionsZ   rN   r   permc                      yNF )r   rQ   rH   s      r   has_permzTokenUser.has_perm]       r   	perm_listc                      yrS   rT   )r   rW   rH   s      r   	has_permszTokenUser.has_perms`   rV   r   modulec                      yrS   rT   )r   rZ   s     r   has_module_permszTokenUser.has_module_permsc   rV   r   c                      yrS   rT   r   s    r   is_anonymouszTokenUser.is_anonymousf   s    r   c                      y)NTrT   r   s    r   is_authenticatedzTokenUser.is_authenticatedj   s    r   c                     | j                   S r   )r!   r   s    r   get_usernamezTokenUser.get_usernamen   s    }}r   attrc                 :    | j                   j                  |d      S )zVThis acts as a backup attribute getter for custom claims defined in Token serializers.Nr#   )r   rc   s     r   __getattr__zTokenUser.__getattr__q   s    zz~~dD))r   )r   r   r   N)r   Nr   ).__name__
__module____qualname____doc__	is_activer   auth_modelsGrouprC   
PermissionrF   r   strr   r	   r   r   r!   boolr&   r(   objectr.   r0   intr3   r8   r;   r?   rA   propertyrD   rG   r   rK   rM   rP   rU   listrY   r\   r^   r`   rb   r   re   rT   r   r   r   r      sQ    I;,,-G$[%;%;<& & 6C 6 6 C   .# . . 1$ 1 1 5d 5 5#F #t #
&F &t &# KKK K KK3 K4 K ))   &+"8"8 & &&)9 S x'7 3 S x'7 4 49 8F3C t s t  d   $  c * * *r   r   N)typingr   r   r   r   django.contrib.authr   rk   django.db.models.managerr   django.utils.functionalr	   settingsr   tokensr   r   rT   r   r   <module>rz      s)    6 6 5 1 3 "f* f*r   