a
    ‹Qx_º  ã                   @   sn   d dl mZ d dlmZ d dlmZmZ d dlmZ G dd„ de	ƒZ
G dd„ deƒZG d	d
„ d
eƒZegZdS )é    )ÚEmailAddress)ÚQUERY_EMAIL)Ú
AuthActionÚProviderAccount)ÚOAuth2Providerc                   @   s   e Zd ZdZdZdS )ÚScopeÚemailZprofileN)Ú__name__Ú
__module__Ú__qualname__ÚEMAILÚPROFILE© r   r   úg/var/www/html/Ranjet/env/lib/python3.9/site-packages/allauth/socialaccount/providers/google/provider.pyr      s   r   c                       s,   e Zd Zdd„ Zdd„ Z‡ fdd„Z‡  ZS )ÚGoogleAccountc                 C   s   | j j d¡S )NÚlink©ÚaccountÚ
extra_dataÚget©Úselfr   r   r   Úget_profile_url   s    zGoogleAccount.get_profile_urlc                 C   s   | j j d¡S )NZpicturer   r   r   r   r   Úget_avatar_url   s    zGoogleAccount.get_avatar_urlc                    s   t t| ƒ ¡ }| jj d|¡S )NÚname)Úsuperr   Úto_strr   r   r   )r   Zdflt©Ú	__class__r   r   r      s    zGoogleAccount.to_str)r	   r
   r   r   r   r   Ú__classcell__r   r   r   r   r      s   r   c                       sH   e Zd ZdZdZeZdd„ Z‡ fdd„Zdd„ Z	d	d
„ Z
dd„ Z‡  ZS )ÚGoogleProviderZgoogleZGooglec                 C   s   t jg}tr| t j¡ |S )N)r   r   r   Úappendr   )r   Zscoper   r   r   Úget_default_scope   s    z GoogleProvider.get_default_scopec                    s(   t t| ƒ ||¡}|tjkr$d|d< |S )Nzselect_account consentÚprompt)r   r    Úget_auth_paramsr   ZREAUTHENTICATE)r   ÚrequestÚactionÚretr   r   r   r$   #   s    
zGoogleProvider.get_auth_paramsc                 C   s   t |d ƒS )NÚid)Ústr©r   Údatar   r   r   Úextract_uid)   s    zGoogleProvider.extract_uidc                 C   s    t | d¡| d¡| d¡dS )Nr   Zfamily_nameZ
given_name)r   Ú	last_nameZ
first_name)Údictr   r*   r   r   r   Úextract_common_fields,   s
    ýz$GoogleProvider.extract_common_fieldsc                 C   s4   g }|  d¡}|r0|  d¡r0| t|ddd¡ |S )Nr   Zverified_emailT)r   ZverifiedZprimary)r   r!   r   )r   r+   r'   r   r   r   r   Úextract_email_addresses3   s
    
z&GoogleProvider.extract_email_addresses)r	   r
   r   r(   r   r   Zaccount_classr"   r$   r,   r/   r0   r   r   r   r   r   r       s   r    N)Zallauth.account.modelsr   Z"allauth.socialaccount.app_settingsr   Z$allauth.socialaccount.providers.baser   r   Z/allauth.socialaccount.providers.oauth2.providerr   Úobjectr   r   r    Zprovider_classesr   r   r   r   Ú<module>   s   #