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!de	dee de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)Optional)forms)
exceptions)HttpRequestHttpResponse)reverse)app_settingssignals)get_adapter)perform_login)Login)context)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/pos/venv/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*   Nr   emailphonereturnc                 C   s   t d ||dd}ttj|S )NT)r   r+   r,   r   )r   r   r   r   )r   r+   r,   loginr   r   r   prevent_enumerationB   s   r/   c                 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+   r0   r   r   r   r   send_unknown_account_mailI   s   r4   c                 C   s    t | d}|st| td}|S )Naccount_signup)r   r   r   )r   urlr   r   r   r2   T   s   
r2   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   r7   r8   r9   r   passkey_signupr   )r
   user_signed_upsend	__class__r   stater   )r   r   r7   r8   r9   r:   r.   r   r   r   complete_signup[   s"   	

rA   )NN)$	importlibr   typingr   djangor   django.corer   django.httpr   r   django.urlsr   allauth.accountr	   r
   allauth.account.adapterr   $allauth.account.internal.flows.loginr   allauth.account.modelsr   allauth.corer   allauth.core.internal.httpkitr   allauth.utilsr   Formr   r*   strr/   r4   r2   rA   r   r   r   r   <module>   s@    )
