
    g<                     r    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 Zdd
Zy	)    wraps)messages)ValidationError)HttpResponseRedirect)reverse)get_adapter)EmailAddressc                     t         j                  j                  | d      j                          }|st	               j                  d      y)z
    If we would allow users to enable 2FA with unverified email address,
    that would allow for an attacker to signup, not verify and prevent the real
    owner of the account from ever regaining access.
    F)userverifiedunverified_emailN)r
   objectsfilterexistsr	   validation_error)r   email_verifieds     [/var/www/django_project/virt/lib/python3.12/site-packages/allauth/mfa/internal/flows/add.pyvalidate_can_add_authenticatorr      sG     &--44$4OVVXXNm,,-?@@     Nc                      d }| r ||       S |S )Nc                 .     t                fd       }|S )Nc                 B   | j                   j                  r	 t        | j                           | g|i |S # t        $ r[}|j                  D ].  }t               }|j                  | t        j                  |       0 t        t        d            cY d }~S d }~ww xY w)N)message	mfa_index)
r   is_authenticatedr   r   r   get_account_adapteradd_messageERRORr   r   )requestargskwargser   adapter	view_funcs         r   _wrapper_viewzEredirect_if_add_not_allowed.<locals>.decorator.<locals>._wrapper_view   s    ||,,F27<<@ W6t6v66 ' F#$:: V"5"7++GX^^W+UV 00DEE	Fs   : 	BABBBr   )r%   r&   s   ` r   	decoratorz.redirect_if_add_not_allowed.<locals>.decorator   s"    	y			7 
		7 r    )functionr'   s     r   redirect_if_add_not_allowedr*      s     ""r   )N)	functoolsr   django.contribr   django.core.exceptionsr   django.httpr   django.urlsr   allauth.account.adapterr	   r   allauth.account.modelsr
   allauth.mfa.adapterr   r*   r(   r   r   <module>r3      s(     # 2 ,  F / +Ar   