retspen / webvirtcloud

WebVirtCloud is virtualization web interface for admins and users
1.63k stars 362 forks source link

Cannot edit LDAP-user #602

Closed thofram closed 9 months ago

thofram commented 9 months ago

When I try to edit a user created by LDAP-logon, I get this error: ERROR: Internal Server Error: /admin/users/2/update/

I cannot make this LDAP user an admin.

thofram commented 9 months ago

From /srv/webvirtcloud/webvirtcloud.log:

[2023-09-22 15:26:33,112] ERROR: Internal Server Error: /admin/users/2/update/ Traceback (most recent call last): File "/srv/webvirtcloud/venv/lib/python3.11/site-packages/django/core/handlers/exception.py", line 55, in inner response = get_response(request) ^^^^^^^^^^^^^^^^^^^^^ File "/srv/webvirtcloud/venv/lib/python3.11/site-packages/django/core/handlers/base.py", line 197, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/srv/webvirtcloud/admin/decorators.py", line 8, in _inner return function(request, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/srv/webvirtcloud/admin/views.py", line 120, in user_update attributes = UserAttributes.objects.get(user=user) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/srv/webvirtcloud/venv/lib/python3.11/site-packages/django/db/models/manager.py", line 87, in manager_method return getattr(self.get_queryset(), name)(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/srv/webvirtcloud/venv/lib/python3.11/site-packages/django/db/models/query.py", line 637, in get raise self.model.DoesNotExist( accounts.models.UserAttributes.DoesNotExist: UserAttributes matching query does not exist.

catborise commented 9 months ago

@krejcar25 do you have any fix/recommendation. Thanks

krejcar25 commented 9 months ago

will check tomorrow @catborise @thofram

krejcar25 commented 9 months ago

this is caused by incorrect use of Django User models. developers are supposed to extend the builtin User model and add attributes this way (doc). the way it's implemented here is through a sidecar model which django-auth-ldap does not know it should create. i will try and find a workaround.

thofram commented 9 months ago

Thank you, I can edit the userprofiles of LDAP-users now.