
    )Jf	                     r    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  G d d          Zd Zd	S )
    )gettext_lazy)app_settings)
user_emailuser_username)context)import_attributec                       e Zd ZdZ ed           ed           ed           ed          dZ	 defdZdefd	Zd
edefdZ	dedefdZ
d ZdS )DefaultMFAAdaptera3  The adapter class allows you to override various functionality of the
    ``allauth.mfa`` app.  To do so, point ``settings.MFA_ADAPTER`` to your own
    class that derives from ``DefaultMFAAdapter`` and override the behavior by
    altering the implementation of the methods according to your own need.
    zYYou cannot activate two-factor authentication until you have verified your email address.zUYou cannot add an email address to an account protected by two-factor authentication.zIncorrect code.z0You cannot deactivate two-factor authentication.)unverified_emailadd_email_blockedincorrect_codecannot_delete_authenticatorreturnc                 h    t          |          }|st          |          }|st          |          }|S )zZReturns the label used for representing the given user in a TOTP QR
        code.
        )r   r   str)selfuserlabels      V/home/alex/cs2snipeproduction/venv/lib/python3.11/site-packages/allauth/mfa/adapter.pyget_totp_labelz DefaultMFAAdapter.get_totp_label   s>     4   	(!$''E 	IIE    c                     t           j        }|sZt          j        r0ddlm} |j                            t          j	                  j
        }nt          j	                                        }|S )zYReturns the TOTP issuer name that will be contained in the TOTP QR
        code.
        r   )Site)r   TOTP_ISSUERallauth_settingsSITES_ENABLEDdjango.contrib.sites.modelsr   objectsget_currentr   requestnameget_host)r   issuerr   s      r   get_totp_issuerz!DefaultMFAAdapter.get_totp_issuer*   se     ) 	4- 4<<<<<<11'/BBG 1133r   textc                     |S )zSecrets such as the TOTP key are stored in the database.  This
        hook can be used to encrypt those so that they are not stored in the
        clear in the database.
         )r   r%   s     r   encryptzDefaultMFAAdapter.encrypt8   s	    
 r   encrypted_textc                 
    |}|S )zCounter part of ``encrypt()``.r'   )r   r)   r%   s      r   decryptzDefaultMFAAdapter.decrypt?   s    r   c                     dS )NTr'   )r   authenticators     r   can_delete_authenticatorz*DefaultMFAAdapter.can_delete_authenticatorD   s    tr   N)__name__
__module____qualname____doc___error_messagesr   r   r$   r(   r+   r.   r'   r   r   r
   r
   
   s         Ag
 
 Qc
 
 !-..'(q>(
 (
 N F	c 	 	 	 	    C C    c c    
    r   r
   c                  D     t          t          j                              S )N)r   r   ADAPTERr'   r   r   get_adapterr7   H   s    1L011333r   N)django.utils.translationr   r3   allauthr   r   allauth.account.utilsr   r   allauth.corer   allauth.mfaallauth.utilsr   r
   r7   r'   r   r   <module>r>      s    6 6 6 6 6 6 4 4 4 4 4 4 ; ; ; ; ; ; ; ;             $ $ $ $ $ $ * * * * * *; ; ; ; ; ; ; ;|4 4 4 4 4r   