MCPcopy
hub / github.com/django/django / _aremove_invalid_user

Method _aremove_invalid_user

django/contrib/auth/middleware.py:264–278  ·  view source on GitHub ↗

Remove the current authenticated user in the request which is invalid but only if the user is authenticated via the RemoteUserBackend.

(self, request)

Source from the content-addressed store, hash-verified

262 auth.logout(request)
263
264 async def _aremove_invalid_user(self, request):
265 """
266 Remove the current authenticated user in the request which is invalid
267 but only if the user is authenticated via the RemoteUserBackend.
268 """
269 try:
270 stored_backend = load_backend(
271 await request.session.aget(auth.BACKEND_SESSION_KEY, "")
272 )
273 except ImportError:
274 # Backend failed to load.
275 await auth.alogout(request)
276 else:
277 if isinstance(stored_backend, RemoteUserBackend):
278 await auth.alogout(request)
279
280
281class PersistentRemoteUserMiddleware(RemoteUserMiddleware):

Callers 1

aprocess_requestMethod · 0.95

Calls 3

load_backendFunction · 0.90
alogoutMethod · 0.80
agetMethod · 0.45

Tested by

no test coverage detected