
    f                        d Z ddlmZ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 ddlmZ ddlmZ ddlmZ ddlmZ dd	lmZ dd
lmZ  eddg          Ze                    dej                   e             ee          fdedefd            Ze                    dej                  e
fdefd            Z dS )z)
Copyright (c) 2019 - present AppSeed.us
    )	APIRouterDependsstatusResponseHTTPExceptionRequest)RedirectResponse)HTMLResponse)OAuth2PasswordRequestForm)Session)appN)get_db)verifyz	/api/authAuthentication)prefixtagsz/login)response_modeluser_credentialsdbc                   K   |                     t          j                                      t          j        j        | j        k                                              }|st          t          j	        d          t          | j        |j                  st          t          j	        d          t          j        d|j        i          }|ddS )NzInvalid Credentials)status_codedetailuser_id)databearer)access_token
token_type)querymodelsTUserfilteremailusernamefirstr   r   HTTP_403_FORBIDDENr   passwordoauth2create_access_tokenid)r   r   userr   s       6/var/www/html/ai4teach/src/routers/auth/auth_routes.pyloginr,      s       88FL!!(();?O?X)XYY__aaD a(AJ_````"+T];; a(AJ_````-i$'5JKKKL *#
 
 
    z/logoutrequestc                   K   | j                             d          }|rDt          t          j                            d                    }|                    dd           |S t          t          j                            d                    S )NAuthorizationsignin home)cookiesgetr	   r   	ui_routerurl_path_for
set_cookie)r.   r   
auth_tokenredirects       r+   logoutr;   -   sy      /%%o66J #CM$>$>x$H$HIIOR000CM66v>>???r-   )!__doc__fastapir   r   r   r   r   r   fastapi.responsesr	   r
   fastapi.security.oauth2r   sqlalchemy.ormr   srcr   src.schemasschemas
src.modelsr   
src.oauth2r'   src.helpers.databaser   src.helpers.utilsr   routerpostTokenr,   r5   r;    r-   r+   <module>rL      s   
 Q P P P P P P P P P P P P P P P . . . . . . * * * * * * = = = = = = " " " " " "                         ' ' ' ' ' ' $ $ $ $ $ $ 

	
 
 

 Xgm44>EgiiW^W^_eWfWf 
 
"; 
W 
 
 
 54
$ Igm442> @ @' @ @ @ 54@ @ @r-   