o
    &zh                     @   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&|d u ri }t  j| ||||d tjr%ddlm} |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 )	N)error	exceptionextra_contextr   internal)providerr   r   r   socialaccount_login_cancelled
auth_error)r   coder   z#socialaccount/authentication_error.)r   on_authentication_errorallauth_settingsHEADLESS_ENABLEDallauth.headless.socialaccountr   r   responser
   	CANCELLEDr   r   updater   account_settingsTEMPLATE_EXTENSION)requestr   r   r   r   r   econtext r    X/var/www/html/kangema/venv/lib/python3.10/site-packages/allauth/socialaccount/helpers.pyrender_authentication_error   sL   

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"    
/