o
    Lf                     @   sX   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d	S )
    )settings)models)timezone)gettext_lazyc                   @   s   e Zd Zdd ZdS )AuthenticatorManagerc                 C   s:   d }t jj|d}|jt jjd s| }|  |S )N)user)type)	AuthenticatorobjectsfilterexcludeTypeRECOVERY_CODESexistsfirstdelete)selfr   deleted_authenticatorqs r   S/var/www/html/humari/django-venv/lib/python3.10/site-packages/allauth/mfa/models.pydelete_dangling_recovery_codes   s   z3AuthenticatorManager.delete_dangling_recovery_codesN)__name__
__module____qualname__r   r   r   r   r   r      s    r   c                   @   s   e Zd ZG dd dejZe Zeje	j
ejdZejdejdZe ZejejdZejddZG d	d
 d
Zdd Zdd Zdd ZdS )r	   c                   @   s$   e Zd ZdedfZdedfZdS )zAuthenticator.Typerecovery_codeszRecovery codestotpzTOTP AuthenticatorN)r   r   r   _r   TOTPr   r   r   r   r      s    r   )	on_delete   )
max_lengthchoices)defaultT)nullc                   @   s   e Zd ZdZdS )zAuthenticator.Meta))r   r   N)r   r   r   unique_togetherr   r   r   r   Meta   s    r&   c                 C   s   |   S )N)get_type_displayr   r   r   r   __str__!   s   zAuthenticator.__str__c                 C   s6   ddl m} ddlm} | jj|| jj|i| j | S )Nr   )RecoveryCodes)r   )allauth.mfa.recovery_codesr*   allauth.mfa.totpr   r   r   r   )r   r*   r   r   r   r   wrap$   s   zAuthenticator.wrapc                 C   s   t  | _| jdgd d S )Nlast_used_at)update_fields)r   nowr.   saver(   r   r   r   record_usage/   s   
zAuthenticator.record_usageN)r   r   r   r   TextChoicesr   r   r
   
ForeignKeyr   AUTH_USER_MODELCASCADEr   	CharFieldr"   r   	JSONFielddataDateTimeFieldr   r0   
created_atr.   r&   r)   r-   r2   r   r   r   r   r	      s    r	   N)django.confr   	django.dbr   django.utilsr   django.utils.translationr   r   Managerr   Modelr	   r   r   r   r   <module>   s    
