@permission_classes((IsAuthenticated,))
@authentication_classes((JSONWebTokenAuthentication,))
@classmethod
def create(cls, request, *args, **kwargs):
    try:
        company_email = request.data['email']
        user_email = request.user.email
        if User.objects.filter(email=user_email, is_corrector=True).exists():
            return JsonResponse({'message': 'ALREADY AUTHENTICATED'}, status=406)
        user = User.objects.get(email=user_email)
        try:
            validate_email(company_email)
            Corrector(user=user, company_email=company_email).save()
        except ValidationError:
            return JsonResponse({'message': 'INVALID EMAIL'}, status=400)
        except PermissionError:
            return JsonResponse({'message': 'PERMISSION ERROR'}, status=401)
        if (company_email.split('@')[1] in cls._COMMON_EMAIL_ADDRESS):
            return JsonResponse({'message': 'NOT COMPANY EMAIL ADDRESS'}, status=400)
        str_host = 'smtp.gmail.com'
        num_port = 587
        emailSender = EmailSender(str_host, num_port)
        str_subject = '[픽소서] EMAIL 인증을 완료해주세요!'
        auth_token = jwt.encode({'email': company_email, 'name': user.name}, SECRET['secret'], algorithm=ALGORITHM).decode('utf-8')
        template = Template(EMAIL_TEMPLATE)
        template_params = {'From': EMAIL_ADDRESS, 'Token': auth_token, 'BackendIp': ip}
        emailHTMLContent = EmailHTMLContent(str_subject, template, template_params)
        str_from_email_addr = EMAIL_ADDRESS
        str_to_email_addr = company_email
        emailSender.send_message(emailHTMLContent, str_from_email_addr, str_to_email_addr)
        User.objects.filter(email=user.email).update(email_auth_token=auth_token)
        return JsonResponse({'message': 'EMAIL SENT', 'EMAIL_AUTH_TOKEN': auth_token}, status=200)
    except KeyError as e:
        return JsonResponse({'message': f'KEY ERROR {e}'}, status=400)
@permission_classes((IsAuthenticated,))
@authentication_classes((JSONWebTokenAuthentication,))
@classmethod
def create(cls, request, *args, **kwargs):
    try:
        company_email = request.data['email']
        user_email = request.user.email
        if User.objects.filter(email=user_email, is_corrector=True).exists():
            return JsonResponse({'message': 'ALREADY AUTHENTICATED'}, status=406)
        user = User.objects.get(email=user_email)
        try:
            validate_email(company_email)
            Corrector(user=user, company_email=company_email).save()
        except ValidationError:
            return JsonResponse({'message': 'INVALID EMAIL'}, status=400)
        except PermissionError:
            return JsonResponse({'message': 'PERMISSION ERROR'}, status=401)
        if (company_email.split('@')[1] in cls._COMMON_EMAIL_ADDRESS):
            return JsonResponse({'message': 'NOT COMPANY EMAIL ADDRESS'}, status=400)
        str_host = 'smtp.gmail.com'
        num_port = 587
        emailSender = EmailSender(str_host, num_port)
        str_subject = '[픽소서] EMAIL 인증을 완료해주세요!'
        auth_token = jwt.encode({'email': company_email, 'name': user.name}, SECRET['secret'], algorithm=ALGORITHM).decode('utf-8')
        template = Template(EMAIL_TEMPLATE)
        template_params = {'From': EMAIL_ADDRESS, 'Token': auth_token, 'BackendIp': ip}
        emailHTMLContent = EmailHTMLContent(str_subject, template, template_params)
        str_from_email_addr = EMAIL_ADDRESS
        str_to_email_addr = company_email
        emailSender.send_message(emailHTMLContent, str_from_email_addr, str_to_email_addr)
        User.objects.filter(email=user.email).update(email_auth_token=auth_token)
        return JsonResponse({'message': 'EMAIL SENT', 'EMAIL_AUTH_TOKEN': auth_token}, status=200)
    except KeyError as e:
        return JsonResponse({'message': f'KEY ERROR {e}'}, status=400)