File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -414,15 +414,15 @@ def directauth(request):
414
414
if not is_valid_token ("ietf.api.views.directauth" , authtoken ):
415
415
return HttpResponse (json .dumps (dict (result = "failure" ,reason = "invalid authtoken" )), content_type = 'application/json' )
416
416
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
419
420
# in the imap server, people's annotations are associated with a very specific login.
420
421
# 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
+
423
423
424
424
# 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 ):
426
426
return HttpResponse (json .dumps (dict (result = "success" )), content_type = 'application/json' )
427
427
428
428
return HttpResponse (json .dumps (dict (result = "failure" , reason = "authentication failed" )), content_type = 'application/json' )
You can’t perform that action at this time.
0 commit comments