o
    Zh                     @  s   d dl mZ d dlZd dlmZ d dlmZ d dlmZ ej	r1d dl
mZ d dlmZ d dlmZ G d	d
 d
eZG dd deZdS )    )annotationsN)DefaultAccountAdapter)DefaultSocialAccountAdapter)settings)SocialLogin)HttpRequest)Userc                   @  s   e Zd ZdddZdS )	AccountAdapterrequestr   returnboolc                 C     t tddS NACCOUNT_ALLOW_REGISTRATIONTgetattrr   )selfr
    r   1/var/www/html/mimamsha/mimansha/users/adapters.pyis_open_for_signup   s   z!AccountAdapter.is_open_for_signupN)r
   r   r   r   )__name__
__module____qualname__r   r   r   r   r   r	      s    r	   c                      s(   e Zd ZdddZd fddZ  ZS )SocialAccountAdapterr
   r   socialloginr   r   r   c                 C  r   r   r   )r   r
   r   r   r   r   r      s   z'SocialAccountAdapter.is_open_for_signupdatadict[str, typing.Any]r   c                   sh   t  |||}|js2|d }r||_|S |d }r2||_|d }r2| jd| 7  _|S )z
        Populates user information from social provider info.

        See: https://docs.allauth.org/en/latest/socialaccount/advanced.html#creating-and-populating-user-instances
        name
first_name	last_name )superpopulate_userr   get)r   r
   r   r   userr   r   r   	__class__r   r   r"      s   z"SocialAccountAdapter.populate_user)r
   r   r   r   r   r   )r
   r   r   r   r   r   r   r   )r   r   r   r   r"   __classcell__r   r   r%   r   r      s    
r   )
__future__r   typingallauth.account.adapterr   allauth.socialaccount.adapterr   django.confr   TYPE_CHECKINGallauth.socialaccount.modelsr   django.httpr   mimansha.users.modelsr   r	   r   r   r   r   r   <module>   s    