o
     e                     @   sn   d dl mZ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	 d	Zd
S )    )TYPE_CHECKINGAnyListOptionalUnion)models)EmptyManager)cached_property   )api_settings)Tokenc                   @   s  e Zd ZdZdZeejZeej	Z
d@ddZdefd	d
Zedeeef fddZedeeef fddZedefddZedefddZedefddZdedefddZdedefddZdefddZdAddZdAddZd eddfd!d"Zd eddfd#d$Zedejfd%d&Z edej	fd'd(Z!dBd)e"e de#fd*d+Z$dBd)e"e de#fd,d-Z%dBd.ed)e"e defd/d0Z&dBd1e'e d)e"e defd2d3Z(d4edefd5d6Z)edefd7d8Z*edefd9d:Z+defd;d<Z,d=ede"e- fd>d?Z.dS )C	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tokenr   returnNc                 C   s
   || _ d S N)r   )selfr    r   R/var/www/html/venv/lib/python3.10/site-packages/rest_framework_simplejwt/models.py__init__      
zTokenUser.__init__c                 C   s   d| j  S )Nz
TokenUser idr   r   r   r   __str__!      zTokenUser.__str__c                 C   s   | j tj S r   )r   r   USER_ID_CLAIMr   r   r   r   r   $   s   zTokenUser.idc                 C      | j S r   r   r   r   r   r   pk(      zTokenUser.pkc                 C      | j ddS )Nusername r   getr   r   r   r   r    ,      zTokenUser.usernamec                 C   r   )Nis_staffFr"   r   r   r   r   r%   0   r$   zTokenUser.is_staffc                 C   r   )Nis_superuserFr"   r   r   r   r   r&   4   r$   zTokenUser.is_superuserotherc                 C   s   t |tstS | j|jkS r   )
isinstancer   NotImplementedr   r   r'   r   r   r   __eq__8   s   
zTokenUser.__eq__c                 C   s   |  | S r   )r+   r*   r   r   r   __ne__=   r   zTokenUser.__ne__c                 C   s
   t | jS r   )hashr   r   r   r   r   __hash__@   r   zTokenUser.__hash__c                 C      t dNz%Token users have no DB representationNotImplementedErrorr   r   r   r   saveC      zTokenUser.savec                 C   r/   r0   r1   r   r   r   r   deleteF   r4   zTokenUser.deleteraw_passwordc                 C   r/   r0   r1   r   r6   r   r   r   set_passwordI   r4   zTokenUser.set_passwordc                 C   r/   r0   r1   r7   r   r   r   check_passwordL   r4   zTokenUser.check_passwordc                 C   r   r   )_groupsr   r   r   r   groupsO   r   zTokenUser.groupsc                 C   r   r   )_user_permissionsr   r   r   r   user_permissionsS   r   zTokenUser.user_permissionsobjc                 C      t  S r   setr   r>   r   r   r   get_group_permissionsW      zTokenUser.get_group_permissionsc                 C   r?   r   r@   rB   r   r   r   get_all_permissionsZ   rD   zTokenUser.get_all_permissionspermc                 C      dS NFr   )r   rF   r>   r   r   r   has_perm]      zTokenUser.has_perm	perm_listc                 C   rG   rH   r   )r   rK   r>   r   r   r   	has_perms`   rJ   zTokenUser.has_permsmodulec                 C   rG   rH   r   )r   rM   r   r   r   has_module_permsc   rJ   zTokenUser.has_module_permsc                 C   rG   rH   r   r   r   r   r   is_anonymousf      zTokenUser.is_anonymousc                 C   rG   )NTr   r   r   r   r   is_authenticatedj   rP   zTokenUser.is_authenticatedc                 C   r   r   )r    r   r   r   r   get_usernamen   rD   zTokenUser.get_usernameattrc                 C   s   | j |dS )zVThis acts as a backup attribute getter for custom claims defined in Token serializers.Nr"   )r   rS   r   r   r   __getattr__q   r$   zTokenUser.__getattr__)r   r   r   N)r   Nr   )/__name__
__module____qualname____doc__	is_activer   auth_modelsGroupr:   
Permissionr<   r   strr   r	   r   intr   r   r    boolr%   r&   objectr+   r,   r.   r3   r5   r8   r9   propertyr;   r=   r   rA   rC   rE   rI   r   rL   rN   rO   rQ   rR   r   rT   r   r   r   r   r      sN    




 r   N)typingr   r   r   r   r   django.contrib.authr   rZ   django.db.models.managerr   django.utils.functionalr	   settingsr   tokensr   r   r   r   r   r   <module>   s    