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 G d
d dejZG dd dejZG dd dejZdS )    )forms)widgets)gettext)get_adapter)EmailAddress)context)	ratelimit)app_settings)device_codesc                       s*   e Zd ZejejdZ fddZ  Z	S )AuthorizationForm)widgetc                    s   | d}| d}t j|i | t   fdd|D }t|dd d}tj|tdtj|d	d
| j	d< t
tjj|d	dddjdd	d}d|v rht|dkrjtjtddd |D dd| j	d< d S d S d S )Nuserrequested_scopesc                    s   g | ]}| j ||fqS  )scope_displayget).0rsadapterr   Q/var/www/html/kangema/venv/lib/python3.10/site-packages/allauth/idp/oidc/forms.py
<listcomp>   s    z.AuthorizationForm.__init__.<locals>.<listcomp>c                 S   s   | d S )N   r   )chr   r   r   <lambda>   s    z,AuthorizationForm.__init__.<locals>.<lambda>)keyzGrant permissionsT)choiceslabelr   initialrequiredscopes)r   verifiedz-primaryemail)flatr   Emailc                 S   s   g | ]}||fqS r   r   )r   r"   r   r   r   r   '   s    F)r   r   r   )popsuper__init__r   sortedr   MultipleChoiceField_CheckboxSelectMultiplefieldslistr   objectsfilterorder_byvalues_listlenChoiceField)selfargskwargsr   r   r   emails	__class__r   r   r'      s4   

zAuthorizationForm.__init__)
__name__
__module____qualname__r   	CharFieldr   HiddenInputrequestr'   __classcell__r   r   r8   r   r      s    r   c                       sJ   e Zd ZejeddejedddddZ fddZd	d
 Z	  Z
S )ConfirmCodeFormCodeTzone-time-code)placeholderautocomplete)attrs)r   r   r   c                    s$   | dd | _t j|i | d S )Ncode)r%   rF   r&   r'   )r4   r5   r6   r8   r   r   r'   5   s   zConfirmCodeForm.__init__c                 C   sD   | j d}tjtjdtjddst 	dt
|\| _| _|S )NrF   device_user_codeT)actionconfig	limit_getrate_limited)cleaned_datar   r   consumer   r?   r	   RATE_LIMITSget_account_adaptervalidation_errorr
   validate_user_codedevice_codeclient)r4   rF   r   r   r   
clean_code9   s   zConfirmCodeForm.clean_code)r:   r;   r<   r   r=   r*   	TextInputrF   r'   rT   r@   r   r   r8   r   rA   ,   s    rA   c                   @   s   e Zd ZejddZdS )DeviceAuthorizationFormF)r   N)r:   r;   r<   r   r=   rH   r   r   r   r   rV   G   s    rV   N)djangor   django.formsr   django.utils.translationr   r*   allauth.account.adapterr   rO   allauth.account.modelsr   allauth.corer   allauth.core.internalr   allauth.idp.oidcr	   allauth.idp.oidc.adapter"allauth.idp.oidc.internal.oauthlibr
   Formr   rA   rV   r   r   r   r   <module>   s    