
    wdf                     R    d dl mZ d dlmZ d dlmZ ddlmZ  G d de          ZdS )	    )unicode_literals)Form)ValidationError   )CSRFTokenFieldc                   ^     e Zd ZdZ e            Zd fd	Zd Zd Ze	 fd            Z
 xZS )	
SecureFormzB
    Form that enables CSRF processing via subclassing hooks.
    N c                      t          t          |           j        |||fi | |                     |          | j        _        dS )z
        :param csrf_context:
            Optional extra data which is passed transparently to your
            CSRF implementation.
        N)superr	   __init__generate_csrf_token
csrf_tokencurrent_token)selfformdataobjprefixcsrf_contextkwargs	__class__s         Z/var/www/book.euthymeo.com/html/venv/lib/python3.11/site-packages/wtforms/ext/csrf/form.pyr   zSecureForm.__init__   sL     	)j$(3II&III(,(@(@(N(N%%%    c                     t                      )a  
        Implementations must override this to provide a method with which one
        can get a CSRF token for this form.

        A CSRF token should be a string which can be generated
        deterministically so that on the form POST, the generated string is
        (usually) the same assuming the user is using the site normally.

        :param csrf_context:
            A transparent object which can be used as contextual info for
            generating the token.
        )NotImplementedError)r   r   s     r   r   zSecureForm.generate_csrf_token   s     "###r   c                 j    |j         |j        k    r"t          |                    d                    dS )z
        Override this method to provide custom CSRF validation logic.

        The default CSRF validation logic simply checks if the recently
        generated token equals the one we received as formdata.
        zInvalid CSRF TokenN)r   datar   gettext)r   fields     r   validate_csrf_tokenzSecureForm.validate_csrf_token'   s7     %*,,!%--0D"E"EFFF -,r   c                 f    t          t          |           j        }|                    d           |S )Nr   )r   r	   r   pop)r   dr   s     r   r   zSecureForm.data1   s,    *d##(	lr   )NNr
   N)__name__
__module____qualname____doc__r   r   r   r   r    propertyr   __classcell__)r   s   @r   r	   r	   	   s           !!JO O O O O O$ $ $G G G     X    r   r	   N)	
__future__r   wtforms.formr   wtforms.validatorsr   fieldsr   r	    r   r   <module>r/      s    ' ' ' ' ' '       . . . . . . " " " " " ", , , , , , , , , ,r   