Skip to content

Commit aebd8dc

Browse files
committed
fix: be stricter in matching User
1 parent 24a0bee commit aebd8dc

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

ietf/api/views.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -414,15 +414,15 @@ def directauth(request):
414414
if not is_valid_token("ietf.api.views.directauth", authtoken):
415415
return HttpResponse(json.dumps(dict(result="failure",reason="invalid authtoken")), content_type='application/json')
416416

417-
user = User.objects.filter(username__iexact=username).first()
418-
# The following would be consistent with auth everywhere else in the app, but until we can map users well
417+
user_query = User.objects.filter(username__iexact=username)
418+
419+
# Matching email would be consistent with auth everywhere else in the app, but until we can map users well
419420
# in the imap server, people's annotations are associated with a very specific login.
420421
# If we get a second user of this API, add an "allow_any_email" argument.
421-
# if not user:
422-
# user = Email.objects.filter(address__iexact=username).first().person.user
422+
423423

424424
# Note well that we are using user.username, not what was passed to the API.
425-
if user and authenticate(username = user.username, password = password):
425+
if user_query.count() == 1 and authenticate(username = user_query.first().username, password = password):
426426
return HttpResponse(json.dumps(dict(result="success")), content_type='application/json')
427427

428428
return HttpResponse(json.dumps(dict(result="failure", reason="authentication failed")), content_type='application/json')

0 commit comments

Comments
 (0)