o
    "4g                     @   s   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 d d	lmZ ejd
d
fddZdd Zdd Zd
S )    )HttpResponseRedirect)render)reverse)app_settings)user_display)ImmediateHttpResponse)get_adapter)flows)	AuthErrorNc              
   C   s   z&t jrddlm} |j| ||||d |d u ri }t j| ||||d W n ty; } z	|jW  Y d }~S d }~ww |tj	krGt
tdS d|||di}|| t| dtj |S )	Nr   internal)providererror	exceptionextra_context)r   r   r   socialaccount_login_cancelled
auth_error)r   coder   z#socialaccount/authentication_error.)allauth_settingsHEADLESS_ENABLEDallauth.headless.socialaccountr   on_authentication_errorr   r   responser
   	CANCELLEDr   r   updater   account_settingsTEMPLATE_EXTENSION)requestr   r   r   r   r   econtext r    f/var/www/html/authentication-server/venv/lib/python3.10/site-packages/allauth/socialaccount/helpers.pyrender_authentication_error   sJ   


r"   c                 C   s,   |j rddlm} || |S tj| |S )Nr   r   )is_headlessr   r   complete_loginr	   login)r   socialloginr   r    r    r!   complete_social_login>   s   r'   c                 C   s   t j}|s
t| jS || S )N)r   SOCIALACCOUNT_STRr   user)socialaccountfuncr    r    r!   socialaccount_user_displayF   s   
r,   )django.httpr   django.shortcutsr   django.urlsr   allauthr   r   allauth.accountr   allauth.account.utilsr   allauth.core.exceptionsr   allauth.socialaccountallauth.socialaccount.adapterr   allauth.socialaccount.internalr	   $allauth.socialaccount.providers.baser
   UNKNOWNr"   r'   r,   r    r    r    r!   <module>   s"    
/