o
    &zh                     @   s   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	d
ddZd	d	ddddededefddZdefddZdee fddZd	S )    )Optional)settings)HttpResponseapp_settings)RateLimited)	ratelimit)Rate)import_callableN)keyuserc                C   s&   ddl m} tj| |j|||d d S )Nr   r   )requestconfigactionr   r   )allauth.accountr   _implclearRATE_LIMITS)r   r   r   r   r    r   Q/var/www/html/kangema/venv/lib/python3.10/site-packages/allauth/core/ratelimit.pyr      s   
r   F)r   r   dry_runraise_exceptionr   r   returnc             	   C   s2   ddl m} tj| |j|||||d}|sdS dS )z
    TODO: We ened to deprecate this module and keep rate limiting internal
    to allauth. This method is using `allauth.account.app_settings` as a
    hard-coded source of settings, which is bad for reusability elsewhere.
    r   r   )r   r   r   r   r   r   r   FT)r   r   r   consumer   )r   r   r   r   r   r   r   usager   r   r   r      s   	r   c              	   C   sj   t jrt| jdrddlm} || S zttjd }t|}W || S  t	t
fy4   tj}Y || S w )Nheadlessr   )RateLimitResponsez.handler429)r   HEADLESS_ENABLEDhasattrallauthallauth.headless.base.responser   r
   r   ROOT_URLCONFImportErrorAttributeErrorr   
handler429)r   r   r$   r   r   r   respond_4297   s   
r%   c                 O   s"   t | g|R i |st| S d S )N)r   r%   )r   argskwargsr   r   r   consume_or_429E   s   r(   )typingr   django.confr   django.httpr   r   r   allauth.core.exceptionsr   allauth.core.internalr   r   allauth.core.internal.ratelimitr	   allauth.utilsr
   r   boolr   r%   r(   r   r   r   r   <module>   s,    
