
    fk              	       F   d dl mZmZ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mZ d dlmZ d dlmZ d dlmZ dededefdZ de!dedeeee   f   fdZ"dee   ddfdZ#defdZ$dedefdZ%dedefdZ&dedefdZ'dede!fdZ(y)    )IterableOptionalTuple)messages)HttpRequest)get_adapter)get_authentication_records)flows)"raise_if_reauthentication_required)Login)signals)delete_and_cleanuppost_authentication)Authenticator)auto_generate_recovery_codes)authrequestpasswordlessreturnc                 H    t        |        t        j                  ||      }|S N)r   r   begin_registration)r   userr   creation_optionss       ^/var/www/cs2snipe.com/venv/lib/python3.12/site-packages/allauth/mfa/webauthn/internal/flows.pyr   r      s#    &w/..t\B    name
credentialc                    t        |        t        j                  j                  | j                  ||      j
                  }t        j                  j                  t        | | j                  |       t        |       }|j                  | t        j                  d       |j                  d| j                         t        |       }||fS )N)senderr   r   authenticatorzmfa/messages/webauthn_added.txtzmfa/email/webauthn_added)r   r   WebAuthnaddr   instancer   authenticator_addedsendr   get_account_adapteradd_messager   SUCCESSsend_notification_mailr   )r   r   r   r!   adapterrc_authenticators         r   add_authenticatorr-      s     'w/MM%% h	 
 $$\\#	 %  "'*G!1!13TU""#=w||L3G<***r   authenticatorsNc                 @    t        |        |D ]  }t        | |        y r   )r   remove_authenticator)r   r.   r!   s      r   remove_authenticatorsr1   5   s#    &w/' 5Wm45r   r!   c                     t        |        t        | |       t        |       }|j                  | t        j
                  d       |j                  d| j                         y )Nz!mfa/messages/webauthn_removed.txtzmfa/email/webauthn_removed)r   r   r'   r(   r   r)   r*   r   )r   r!   r+   s      r   r0   r0   ;   sL    &w/w.!'*G!1!13VW""#?Nr   loginc                 ^    t        | |d       t        j                  j                  | |      S )NT)r   )r   r
   r3   perform_login)r   r!   r3   s      r   perform_passwordless_loginr6   C   s%    TB;;$$We44r   c                 <    t        |       }t        d |D              S )Nc              3      K   | ]9  }|j                  d       |j                  d      |j                  d      fdk(   ; yw)methodtyper   )mfawebauthnTN)get).0records     r   	<genexpr>z-did_use_passwordless_login.<locals>.<genexpr>J   sD        
H	vzz&16::n3MN$	%s   ?A)r	   any)r   recordss     r   did_use_passwordless_loginrC   H   s(    (1G    r   c                      t        | |d       y )NT)reauthenticated)r   )r   r!   s     r   reauthenticaterF   Q   s    Er   c                 h    t        |        |j                         }||_        |j                          y r   )r   wrapr   save)r   r!   r   wrappers       r   rename_authenticatorrK   U   s+    &w/  "GGLr   ))typingr   r   r   django.contribr   django.httpr   allauth.account.adapterr   r'   allauth.account.authenticationr	   allauth.account.internalr
   /allauth.account.internal.flows.reauthenticationr   allauth.account.modelsr   allauth.mfar   allauth.mfa.base.internal.flowsr   r   allauth.mfa.modelsr   )allauth.mfa.recovery_codes.internal.flowsr   allauth.mfa.webauthn.internalr   booldictr   strr-   r1   r0   r6   rC   rF   rK    r   r   <module>r]      s    , , # # F E * )  - /  $ ++$(+
=(=112+,58M3J 5t 5O O5} 5U 5
  FK F F c r   