Skip to content

Commit

Permalink
allow dots in email lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
felixrindt committed Mar 28, 2024
1 parent ede5048 commit 9238de8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions ephios/api/views/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ class UserByMailView(RetrieveModelMixin, GenericViewSet):
filter_backends = [ObjectPermissionsFilter]
lookup_url_kwarg = "email"
lookup_field = "email"
lookup_value_regex = "[^/]+" # customize to allow dots (".") in the lookup value
schema = AutoSchema(operation_id_base="UserProfileByMail")


Expand Down
21 changes: 21 additions & 0 deletions tests/api/test_user.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from django.urls import reverse


def test_user_profile_list(django_app, groups, superuser):
response = django_app.get(reverse("api:userprofile-list"), user=superuser)
assert superuser.email in response


def test_api_user_profile_by_email(django_app, superuser):
superuser.email = "special-char.123@toplevel.berlin"
superuser.save()
response = django_app.get(
reverse(
"api:user-by-email-detail",
kwargs={
"email": superuser.email,
},
),
user=superuser,
)
assert superuser.email in response

0 comments on commit 9238de8

Please sign in to comment.