Skip to content
This repository was archived by the owner on Apr 29, 2022. It is now read-only.
This repository was archived by the owner on Apr 29, 2022. It is now read-only.

500 when using the Doppelgänger function in the Django Admin #1388

Open
@malemburg

Description

@malemburg

In some cases, we're getting a 500 when using the Doppelgänger function on user accounts. Apparently, this happens whenever a user has not been activated yet.

Here's an example traceback:

Traceback:

File "/usr/local/lib/python3.8/site-packages/django/contrib/auth/__init__.py" in login
  111.         backend = backend or user.backend

During handling of the above exception ('AnonymousUser' object has no attribute 'backend'), another exception occurred:

File "/usr/local/lib/python3.8/site-packages/django/core/handlers/exception.py" in inner
  34.             response = get_response(request)

File "/usr/local/lib/python3.8/site-packages/django/core/handlers/base.py" in _get_response
  115.                 response = self.process_exception_by_middleware(e, request)

File "/usr/local/lib/python3.8/site-packages/django/core/handlers/base.py" in _get_response
  113.                 response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/usr/local/lib/python3.8/site-packages/django/utils/decorators.py" in _wrapped_view
  142.                     response = view_func(request, *args, **kwargs)

File "/usr/local/lib/python3.8/site-packages/django/views/decorators/cache.py" in _wrapped_view_func
  44.         response = view_func(request, *args, **kwargs)

File "/usr/local/lib/python3.8/site-packages/django/contrib/admin/sites.py" in inner
  223.             return view(request, *args, **kwargs)

File "/usr/src/ep2021/assopy/admin.py" in create_doppelganger
  436.         auth.login(request, user)

File "/usr/local/lib/python3.8/site-packages/django/contrib/auth/__init__.py" in login
  117.             raise ValueError(

Exception Type: ValueError at /admin/auth/user/xxxx/login/
Exception Value: You have multiple authentication backends configured and therefore must provide the `backend` argument or set the `backend` attribute on the user.

SO suggests adding a backend parameter: https://stackoverflow.com/questions/45961459/multiple-authentication-backends-configured-and-therefore-must-provide-the-back, however, it's possible that we simply need to just return an error saying that the user has not been activated yet, so the Doppelgänger function doesn't work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    2022buggoodfirstissueIf you've never contributed to epcon before – this should be easiest to start with

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions