o
    ߭h                     @   s   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 d dlmZ d dlmZmZmZmZmZ zd d	lmZ d d
lmZ d dlmZ W n ey]   eZY nw G dd deejejf Z dS )    )Sequence)GenericOptional)	APIRouter)modelsschemas)AuthenticationBackendAuthenticator)
SecretType)UserManagerDependency)get_auth_routerget_register_routerget_reset_password_routerget_users_routerget_verify_router)
BaseOAuth2)get_oauth_router)get_oauth_associate_routerc                   @   s\  e Zd ZU dZeejejf ed< de	ejejf de
eejejf  fddZdeej deej d	efd
dZdeej d	efddZd	efddZ	d"deejejf ded	efddZ			d#dedeejejf dedee deded	efddZ		d$dedeej dedee ded	efddZ	d"deej deej ded	efd d!ZdS )%FastAPIUsersap  
    Main object that ties together the component for users authentication.

    :param get_user_manager: Dependency callable getter to inject the
    user manager class instance.
    :param auth_backends: List of authentication backends.

    :attribute current_user: Dependency callable getter to inject authenticated user
    with a specific set of parameters.
    authenticatorget_user_managerauth_backendsc                 C   s    t ||| _|| _| jj| _d S )N)r	   r   r   current_user)selfr   r    r   `/var/www/html/stock_analysis/be/venv/lib/python3.10/site-packages/fastapi_users/fastapi_users.py__init__)   s   zFastAPIUsers.__init__user_schemauser_create_schemareturnc                 C   s   t | j||S )z
        Return a router with a register route.

        :param user_schema: Pydantic schema of a public user.
        :param user_create_schema: Pydantic schema for creating a user.
        )r   r   )r   r   r   r   r   r   r   2   s   	z FastAPIUsers.get_register_routerc                 C   s   t | j|S )z
        Return a router with e-mail verification routes.

        :param user_schema: Pydantic schema of a public user.
        )r   r   )r   r   r   r   r   r   ?   s   zFastAPIUsers.get_verify_routerc                 C   s
   t | jS )z'Return a reset password process router.)r   r   )r   r   r   r   r   G   s   
z&FastAPIUsers.get_reset_password_routerFbackendrequires_verificationc                 C   s   t || j| j|S )a  
        Return an auth router for a given authentication backend.

        :param backend: The authentication backend instance.
        :param requires_verification: Whether the authentication
        require the user to be verified or not. Defaults to False.
        )r   r   r   )r   r    r!   r   r   r   r   K   s   zFastAPIUsers.get_auth_routerNoauth_clientstate_secretredirect_urlassociate_by_emailis_verified_by_defaultc                 C   s   t ||| j||||S )a5  
        Return an OAuth router for a given OAuth client and authentication backend.

        :param oauth_client: The HTTPX OAuth client instance.
        :param backend: The authentication backend instance.
        :param state_secret: Secret used to encode the state JWT.
        :param redirect_url: Optional arbitrary redirect URL for the OAuth2 flow.
        If not given, the URL to the callback endpoint will be generated.
        :param associate_by_email: If True, any existing user with the same
        e-mail address will be associated to this user. Defaults to False.
        :param is_verified_by_default: If True, the `is_verified` flag will be
        set to `True` on newly created user. Make sure the OAuth Provider you're
        using does verify the email address before enabling this flag.
        )r   r   )r   r"   r    r#   r$   r%   r&   r   r   r   r   ^   s   zFastAPIUsers.get_oauth_routerc                 C   s   t || j| j||||S )a)  
        Return an OAuth association router for a given OAuth client.

        :param oauth_client: The HTTPX OAuth client instance.
        :param user_schema: Pydantic schema of a public user.
        :param state_secret: Secret used to encode the state JWT.
        :param redirect_url: Optional arbitrary redirect URL for the OAuth2 flow.
        If not given, the URL to the callback endpoint will be generated.
        :param requires_verification: Whether the endpoints
        require the users to be verified or not. Defaults to False.
        )r   r   r   )r   r"   r   r#   r$   r!   r   r   r   r      s   z'FastAPIUsers.get_oauth_associate_routeruser_update_schemac                 C   s   t | j||| j|S )aE  
        Return a router with routes to manage users.

        :param user_schema: Pydantic schema of a public user.
        :param user_update_schema: Pydantic schema for updating a user.
        :param requires_verification: Whether the endpoints
        require the users to be verified or not. Defaults to False.
        )r   r   r   )r   r   r'   r!   r   r   r   r      s   zFastAPIUsers.get_users_router)F)NFF)NF)__name__
__module____qualname____doc__r	   r   UPID__annotations__r   r   r   r   typer   UUCr   r   r   r   boolr   r   r
   r   strr   r   UUr   r   r   r   r   r      s   
 
	


&
!r   N)!collections.abcr   typingr   r   fastapir   fastapi_usersr   r   fastapi_users.authenticationr   r	   fastapi_users.jwtr
   fastapi_users.managerr   fastapi_users.routerr   r   r   r   r   httpx_oauth.oauth2r   r   fastapi_users.router.oauthr   ModuleNotFoundErrorr/   r,   r-   r   r   r   r   r   <module>   s      