o
    ߭h                     @   st   d dl mZ d dl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 G dd deejejf Zd	S )
    )Generic)Responsestatus)models)Strategy StrategyDestroyNotSupportedError)	Transport TransportLogoutNotSupportedError)DependencyCallablec                	   @   s   e Zd ZU dZeed< eed< dededeee	j
e	jf  fddZdee	j
e	jf de	j
d	efd
dZdee	j
e	jf de	j
ded	efddZdS )AuthenticationBackendaB  
    Combination of an authentication transport and strategy.

    Together, they provide a full authentication method logic.

    :param name: Name of the backend.
    :param transport: Authentication transport instance.
    :param get_strategy: Dependency callable returning
    an authentication strategy instance.
    name	transportget_strategyc                 C   s   || _ || _|| _d S N)r   r   r   )selfr   r   r    r   i/var/www/html/stock_analysis/be/venv/lib/python3.10/site-packages/fastapi_users/authentication/backend.py__init__    s   
zAuthenticationBackend.__init__strategyuserreturnc                    s$   | |I d H }| j|I d H S r   )write_tokenr   get_login_response)r   r   r   tokenr   r   r   login*   s   zAuthenticationBackend.loginr   c                    sd   z| ||I d H  W n	 ty   Y nw z| j I d H }W |S  ty1   ttjd}Y |S w )N)status_code)destroy_tokenr   r   get_logout_responser	   r   r   HTTP_204_NO_CONTENT)r   r   r   r   responser   r   r   logout0   s   zAuthenticationBackend.logoutN)__name__
__module____qualname____doc__str__annotations__r   r
   r   r   UPIDr   r   r   r    r   r   r   r   r      s6   
 


r   N)typingr   fastapir   r   fastapi_usersr   %fastapi_users.authentication.strategyr   r   &fastapi_users.authentication.transportr   r	   fastapi_users.typesr
   r'   r(   r   r   r   r   r   <module>   s     