o
    h                     @   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	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 dlmZ d dlmZ d dlmZ G dd dejZdd Zde	dede
fddZ de	deddfddZ!de	defddZ"dddddddZ#dS )     )import_module)forms)messages)
exceptions)HttpRequestHttpResponse)reverse)app_settingssignals)get_adapter)email_verification_by_code)perform_login)Login)get_frontend_url)build_absolute_uric                   @   s   e Zd Zdd ZdS )DummyCustomSignupFormc                 C   s   dS )zL
        Invoked at signup time to complete the signup of the user.
        N )selfrequestuserr   r   `/var/www/html/env_mimamsha/lib/python3.10/site-packages/allauth/account/internal/flows/signup.pysignup   s   zDummyCustomSignupForm.signupN)__name__
__module____qualname__r   r   r   r   r   r      s    r   c               
   C   s   t jstS zt jdd\} }W n ty   tdt j w zt| }W n ty; } z	td| |f d}~ww zt	||}W n t
yS   td| |f w t|ds^td|S )	a  
    Currently, we inherit from the custom form, if any. This is all
    not very elegant, though it serves a purpose:

    - There are two signup forms: one for local accounts, and one for
      social accounts
    - Both share a common base (BaseSignupForm)

    - Given the above, how to put in a custom signup form? Which form
      would your custom form derive from, the local or the social one?
    .   z!%s does not point to a form classz#Error importing form class %s: "%s"Nz(Module "%s" does not define a "%s" classr   zLThe custom signup form must offer a `def signup(self, request, user)` method)r	   SIGNUP_FORM_CLASSr   rsplit
ValueErrorr   ImproperlyConfiguredr   ImportErrorgetattrAttributeErrorhasattr)	fc_modulefc_classnamemodefc_classr   r   r   base_signup_form_class   s:   


r*   r   emailreturnc              	   C   sT   t | }|| || tjd|ddd tjr"tjj	| d |d |
| d }|S )Nz,account/messages/email_confirmation_sent.txtFT)r+   loginr   )r   r   r+   )r    send_account_already_exists_mailadd_messager   INFOr	   "EMAIL_VERIFICATION_BY_CODE_ENABLEDr   EmailVerificationProcessinitiaterespond_email_verification_sent)r   r+   adapterrespr   r   r   prevent_enumerationB   s   

r7   Nc                 C   s0   t jsd S t| }| |d}t d|| d S )N)r   
signup_urlzaccount/email/unknown_account)r	   EMAIL_UNKNOWN_ACCOUNTSget_signup_urlr   	send_mail)r   r+   r8   contextr   r   r   send_unknown_account_mailS   s   r=   c                 C   s    t | d}|st| td}|S )Naccount_signup)r   r   r   )r   urlr   r   r   r:   ^   s   
r:   F)email_verificationredirect_urlsignal_kwargs
by_passkeyc                C   sR   |d u ri }t jjd|j| |d| t||||dd}|r$d|jd< t| |S )N)senderr   r   T)r   r@   rA   rB   r   passkey_signupr   )r
   user_signed_upsend	__class__r   stater   )r   r   r@   rA   rB   rC   r-   r   r   r   complete_signupe   s"   	

rJ   )$	importlibr   djangor   django.contribr   django.corer   django.httpr   r   django.urlsr   allauth.accountr	   r
   allauth.account.adapterr   allauth.account.internal.flowsr   $allauth.account.internal.flows.loginr   allauth.account.modelsr   allauth.core.internal.httpkitr   allauth.utilsr   Formr   r*   strr7   r=   r:   rJ   r   r   r   r   <module>   s.    (