#36819: Async login does not reuse authenticated user instance
-------------------------------------+-------------------------------------
     Reporter:  Mykhailo Havelia     |                    Owner:  (none)
         Type:                       |                   Status:  closed
  Cleanup/optimization               |
    Component:  contrib.auth         |                  Version:  6.0
     Severity:  Normal               |               Resolution:  wontfix
     Keywords:  async auser alogin   |             Triage Stage:
  cache                              |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Comment (by Mykhailo Havelia):

 Replying to [comment:1 Natalia Bidart]:

 > why a project would mix async and sync in the same flow, and

 There is no mixing of sync and async within the same flow. The issue is
 that after calling alogin and awaiting `request.auser()`, we end up
 performing redundant authentication requests (at least against the
 database).

 > a shared cache feels like the perfect recipe for a debugging nightmare

 It's just one of the options how to solve it. Btw 🙂 that "perfect recipe
 for a debugging nightmare" already exists in the current codebase. For
 example:

 {{{
 async def alogin(request, user, backend=None):
     ...
     request.user = user
 }}}

 Here, `alogin` is an async function that mutates request.user, which is
 part of the synchronous API.
-- 
Ticket URL: <https://code.djangoproject.com/ticket/36819#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/django-updates/0107019b4d709015-43836763-86a0-4f68-8382-fc1f60a71df5-000000%40eu-central-1.amazonses.com.

Reply via email to