Skip to content

Commit 023a547

Browse files
fix: revert "fix: check-split-length-before-accessing-with-index" (#5943)
1 parent f70b8d2 commit 023a547

5 files changed

Lines changed: 4 additions & 49 deletions

File tree

api/custom_auth/serializers.py

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
1-
import re
21
from typing import Any
32

43
from common.core.utils import is_saas
54
from django.conf import settings
6-
from djoser.serializers import ( # type: ignore[import-untyped]
7-
TokenCreateSerializer,
8-
UserCreateSerializer,
9-
)
5+
from djoser.serializers import UserCreateSerializer # type: ignore[import-untyped]
106
from rest_framework import serializers
117
from rest_framework.authtoken.models import Token
128
from rest_framework.exceptions import PermissionDenied
@@ -23,15 +19,6 @@
2319
USER_REGISTRATION_WITHOUT_INVITE_ERROR_MESSAGE,
2420
)
2521

26-
EMAIL_REGEX = re.compile(r"^[^@]+@(?:\w+\.)+\w{2,}$")
27-
28-
29-
class CustomTokenCreateSerializer(TokenCreateSerializer): # type: ignore[misc]
30-
def validate_email(self, value: str) -> str:
31-
if not EMAIL_REGEX.match(value):
32-
raise serializers.ValidationError("Invalid email format.")
33-
return value
34-
3522

3623
class CustomTokenSerializer(serializers.ModelSerializer): # type: ignore[type-arg]
3724
class Meta:

api/custom_auth/views.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
from custom_auth.mfa.trench.responses import ErrorResponse
3131
from custom_auth.mfa.trench.serializers import CodeLoginSerializer
3232
from custom_auth.mfa.trench.utils import user_token_generator
33-
from custom_auth.serializers import CustomTokenCreateSerializer, CustomUserDelete
33+
from custom_auth.serializers import CustomUserDelete
3434
from integrations.lead_tracking.hubspot.services import (
3535
register_hubspot_tracker_and_track_user,
3636
)
@@ -46,7 +46,6 @@ class CustomAuthTokenLoginOrRequestMFACode(TokenCreateView): # type: ignore[mis
4646
Class to handle throttling for login requests
4747
"""
4848

49-
serializer_class = CustomTokenCreateSerializer
5049
authentication_classes = [] # type: ignore[var-annotated]
5150
throttle_classes = [ScopedRateThrottle]
5251
throttle_scope = "login"

api/integrations/lead_tracking/hubspot/services.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,7 @@ def register_hubspot_tracker(
6969
def create_self_hosted_onboarding_lead(
7070
email: str, first_name: str, last_name: str, organisation_name: str
7171
) -> None:
72-
email_parts = email.split("@")
73-
email_domain = email_parts[1] if len(email_parts) > 1 else organisation_name
72+
email_domain = email.split("@")[1]
7473
hubspot_client = HubspotClient()
7574
company = hubspot_client.get_company_by_domain(email_domain)
7675
if not company:

api/tests/integration/custom_auth/end_to_end/test_custom_auth_integration.py

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -746,33 +746,3 @@ def test_marketing_consent_given_defaults_to_true(
746746
# Then
747747
assert response.status_code == status.HTTP_201_CREATED
748748
assert response.json()["marketing_consent_given"] is True
749-
750-
751-
@pytest.mark.parametrize(
752-
"invalid_email",
753-
[
754-
"invalid_email",
755-
"12345",
756-
"invalid@email@com.com",
757-
"invalid_email.com",
758-
"invalid_email@com",
759-
"foo@..!.bar.",
760-
],
761-
)
762-
def test_create_user_returns_error_if_email_is_invalid(
763-
staff_client: APIClient,
764-
invalid_email: str,
765-
) -> None:
766-
# Given
767-
url = reverse("api-v1:custom_auth:custom-mfa-authtoken-login")
768-
register_data = {
769-
"email": invalid_email,
770-
"password": "password",
771-
}
772-
773-
# When
774-
response = staff_client.post(url, data=register_data)
775-
776-
# Then
777-
assert response.status_code == status.HTTP_400_BAD_REQUEST
778-
assert response.json()["email"][0] == "Invalid email format."

api/tests/unit/users/test_unit_users_models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,5 +241,5 @@ def test_delete_user(): # type: ignore[no-untyped-def]
241241
assert Organisation.objects.filter(name="org1").count() == 1
242242

243243

244-
def test_user_email_domain_property() -> None:
244+
def test_user_email_domain_property(): # type: ignore[no-untyped-def]
245245
assert FFAdminUser(email="test@example.com").email_domain == "example.com"

0 commit comments

Comments
 (0)