U
    `                     @   sZ   d dl mZ d dlmZ dd Zdd Zdd Zzd	d
lmZ W n e	k
rT   Y nX dS )    )import_module)settingsc                 C   s>   t | dr| S t| tst| dd\}}tt||S d S )N__call__.   )hasattr
isinstancestrAssertionErrorrsplitgetattrr   )path_or_callablepackageattr r   :/Users/michael/Projects/dj-rest-auth/dj_rest_auth/utils.pyimport_callable   s
    
r   c                 C   s   | j j|d\}}|S )N)user)objectsget_or_create)Ztoken_modelr   
serializertoken_r   r   r   default_create_token   s    r   c                 C   s@   ddl m} ttdi }|d|}t|}|| }|j|fS )Nr   )TokenObtainPairSerializerREST_AUTH_SERIALIZERSJWT_TOKEN_CLAIMS_SERIALIZER)$rest_framework_simplejwt.serializersr   r   r   getr   	get_tokenaccess_token)r   r   Zrest_auth_serializersZJWTTokenClaimsSerializerZTOPSrefreshr   r   r   
jwt_encode   s    
r"   r   )JWTCookieAuthenticationN)
	importlibr   django.confr   r   r   r"   Zjwt_authr#   ImportErrorr   r   r   r   <module>   s   	