
    0gi\                     J    d dl mZ d dlmZ d dlmZ d dlmZ  G d de      Zy)    )TokenObtainPairSerializer)APIException)UserCompanyRole)validate_user_contextc                        e Zd Z fdZ xZS )CustomTokenObtainPairSerializerc                     t         |   |      }| j                  }|j                  dk(  r|S t	        |dd       }|r|j
                  rd|j                  dS t        |       |S )Nsuper_admin
two_factorT)two_factor_requireduser_id)supervalidateuser	user_typegetattr
is_enabledidr   )selfattrsdatar   r   	__class__s        C/var/www/html/dp2/backend_v2.1/server/apps/core/serializers/auth.pyr   z(CustomTokenObtainPairSerializer.validate
   sj    w&yy>>]*KT<6
*//'+77 
 	d#2     )__name__
__module____qualname__r   __classcell__)r   s   @r   r   r      s    ) )r   r   N)	$rest_framework_simplejwt.serializersr   rest_framework.exceptionsr   apps.permissions.modelsr   apps.core.servicesr   r    r   r   <module>r$      s    J 2 3 5+&? +r   