
    f
                         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
mZ d dlmZ d dlmZ defd	Zdefd
Zdee   fdZdee   fdZy)    )Optional)messages)get_adapter)"raise_if_reauthentication_required)app_settingssignals)Authenticator)RecoveryCodesreturnc                     t         j                  j                  |       j                  t         j                  j
                        j                         S )Nuser)type)r	   objectsfilterexcludeTypeRECOVERY_CODESexistsr   s    d/var/www/cs2snipe.com/venv/lib/python3.12/site-packages/allauth/mfa/recovery_codes/internal/flows.pycan_generate_recovery_codesr      s=    $$$$/	m((77	8	    c                    t        |        t        j                  j                  | j                  t        j
                  j                        j                          t        j                  | j                        }|j                  }t        |       }|j                  | t        j                  d       t        j                   j#                  t        | | j                  |       |j%                  d| j                         |S )Nr   r   )mfa/messages/recovery_codes_generated.txtsenderrequestr   authenticatorz"mfa/email/recovery_codes_generated)r   r	   r   r   r   r   r   deleter
   activateinstanceget_account_adapteradd_messager   SUCCESSr   authenticator_resetsendsend_notification_mail)r   rc_authr   adapters       r   generate_recovery_codesr+      s    &w/  \\ 2 2 A A ! fh$$W\\2G$$M!'*G!!#N $$\\#	 %  ""#GVr   c                     t         j                  j                  | j                  t         j                  j
                        j                         }|sy t        |        |S )Nr   )r	   r   r   r   r   r   firstr   )r   r   s     r   view_recovery_codesr.   +   sU    !))00\\.. 1  eg  &w/r   c                 $   t         j                  j                  t        j                  vryt         j
                  j                  | j                  t         j                  j                        j                         }|ryt        j                  | j                        }t        j                  j                  t         | | j                  |j                         t        |       }|j!                  | t"        j$                  d       |j                  S )zAutomatically (implicitly) setup recovery codes when another
    authenticator is setup for. As this is part of setting up another (primary)
    authenticator, we do not send a notification email in this case.
    Nr   r   r   )r	   r   r   r   SUPPORTED_TYPESr   r   r   r   r
   r!   r   authenticator_addedr'   r"   r#   r$   r   r%   )r   has_rcrcr*   s       r   auto_generate_recovery_codesr4   6   s    
 ((0L0LL""))\\ 2 2 A A * fh  				-B$$\\kk	 %  "'*G!!#N ;;r   N)typingr   django.contribr   allauth.account.adapterr   r#   /allauth.account.internal.flows.reauthenticationr   allauth.mfar   r   allauth.mfa.modelsr	   (allauth.mfa.recovery_codes.internal.authr
   boolr   r+   r.   r4    r   r   <module>r>      sX     # F . , B  *H]$; Xm-D r   