o
    gëfÃ  ã                   @   s\   d Z ddlZddlmZmZ ddlmZ dZdZG dd„ deƒZ	G d	d
„ d
eƒZ
de
iZdS )z¯
LiveJournal OpenID support.

This contribution adds support for LiveJournal OpenID service in the form
username.livejournal.com. Username is retrieved from the identity url.
é    N)ÚOpenIDBackendÚ
OpenIdAuth)ÚAuthMissingParameterzhttp://%s.livejournal.comÚopenid_lj_userc                       s$   e Zd ZdZdZ‡ fdd„Z‡  ZS )ÚLiveJournalBackendz)LiveJournal OpenID authentication backendÚlivejournalc                    s<   t t| ƒ |¡}| d¡pt |j¡j dd¡d |d< |S )z#Generate username from identity urlÚusernameÚ.é   r   )	Úsuperr   Úget_user_detailsÚgetÚurlparseÚurlsplitÚidentity_urlÚnetlocÚsplit)ÚselfÚresponseÚvalues©Ú	__class__© úi/var/www/html/humari/django-venv/lib/python3.10/site-packages/social_auth/backends/contrib/livejournal.pyr      s   

ÿÿz#LiveJournalBackend.get_user_details)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Únamer   Ú__classcell__r   r   r   r   r      s    r   c                   @   s$   e Zd ZdZeZdd„ Zdd„ ZdS )ÚLiveJournalAuthz!LiveJournal OpenID authenticationc                 C   s   dS )zLiveJournal uses redirectTr   ©r   r   r   r   Úuses_redirect#   s   zLiveJournalAuth.uses_redirectc                 C   s$   | j  t¡st| tƒ‚t| j t  S )z&Returns LiveJournal authentication URL)Údatar   ÚLIVEJOURNAL_USER_FIELDr   ÚLIVEJOURNAL_URLr!   r   r   r   Ú
openid_url'   s   
zLiveJournalAuth.openid_urlN)r   r   r   r   r   ÚAUTH_BACKENDr"   r&   r   r   r   r   r       s
    r    r   )r   r   Úsocial_auth.backendsr   r   Úsocial_auth.exceptionsr   r%   r$   r   r    ÚBACKENDSr   r   r   r   Ú<module>   s    ÿ