
    )Jf                     \    d dl mZ d dlmZ  G d de          Z G d de          ZegZdS )    )ProviderAccount)OAuth2Providerc                   $     e Zd Zd Z fdZ xZS )DataportenAccountc                 0    d}|| j         j        d         z   S )zJ
        Returns a valid URL to an 128x128 .png photo of the user
        z1https://api.dataporten.no/userinfo/v1/user/media/profilephoto)account
extra_data)selfbase_urls     v/home/alex/cs2snipeproduction/venv/lib/python3.11/site-packages/allauth/socialaccount/providers/dataporten/provider.pyget_avatar_urlz DataportenAccount.get_avatar_url   s     G$,1.AAA    c                     t          t          |                                           }| j        j                            dd          d|dS )zk
        Returns string representation of a social account. Includes the name
        of the user.
        name z ())superr   to_strr	   r
   get)r   dflt	__class__s     r   r   zDataportenAccount.to_str   sP    
 &--4466L#''3333DD
 	
r   )__name__
__module____qualname__r   r   __classcell__)r   s   @r   r   r      sJ        B B B	
 	
 	
 	
 	
 	
 	
 	
 	
r   r   c                   ,    e Zd ZdZdZeZd Zd Zd Z	dS )DataportenProvider
dataporten
Dataportenc                     |d         S )zz
        Returns the primary user identifier, an UUID string
        See: https://docs.dataporten.no/docs/userid/
        userid r   datas     r   extract_uidzDataportenProvider.extract_uid    s    
 H~r   c                     |S )u  
        Extracts fields from `data` that will be stored in
        `SocialAccount`'s `extra_data` JSONField.

        All the necessary data extraction has already been done in the
        complete_login()-view, so we can just return the data.
        PS: This is default behaviour, so we did not really need to define
            this function, but it is included for documentation purposes.

        Typical return dict:
        {
            "userid": "76a7a061-3c55-430d-8ee0-6f82ec42501f",
            "userid_sec": ["feide:andreas@uninett.no"],
            "name": "Andreas Åkre Solberg",
            "email": "andreas.solberg@uninett.no",
            "profilephoto": "p:a3019954-902f-45a3-b4ee-bca7b48ab507",
        }
        r#   r$   s     r   extract_extra_dataz%DataportenProvider.extract_extra_data'   s	    & r   c                 2   t          |          }|                    d          D ]@}|                    d          \  }}|dk    r |                    d          d         |d<    n2A|                    d                              d          d         |d<   |S )uv  
        This function extracts information from the /userinfo endpoint which
        will be consumed by allauth.socialaccount.adapter.populate_user().
        Look there to find which key-value pairs that should be saved in the
        returned dict.

        Typical return dict:
        {
            "userid": "76a7a061-3c55-430d-8ee0-6f82ec42501f",
            "userid_sec": ["feide:andreas@uninett.no"],
            "name": "Andreas Åkre Solberg",
            "email": "andreas.solberg@uninett.no",
            "profilephoto": "p:a3019954-902f-45a3-b4ee-bca7b48ab507",
            "username": "andreas",
        }
        
userid_sec:feide@r   usernameemail)dictr   split)r   r%   r"   usertyper.   s        r   extract_common_fieldsz(DataportenProvider.extract_common_fields<   s    $ Dzz hh|,, 	? 	?F!'c!2!2Hh7""#+>>##6#6q#9Z  #
  $xx0066s;;A>Dr   N)
r   r   r   idr   r   account_classr&   r(   r3   r#   r   r   r   r      sP        	BD%M    *    r   r   N)$allauth.socialaccount.providers.baser   /allauth.socialaccount.providers.oauth2.providerr   r   r   provider_classesr#   r   r   <module>r9      s    @ @ @ @ @ @ J J J J J J
 
 
 
 
 
 
 
,@ @ @ @ @ @ @ @F ''   r   