[GH-ISSUE #937] Broken User #803

Closed
opened 2026-02-27 11:13:37 +03:00 by kerem · 5 comments
Owner

Originally created by @hennedo on GitHub (Oct 10, 2016).
Original GitHub issue: https://github.com/modoboa/modoboa/issues/937

Originally assigned to: @tonioo on GitHub.

I have some broken users, as a SuperAdmin i cannot delete those, or change their role from SimpleUser to DomainAdmin (which the user was before I degraded him to SimpleUser..)

For example the user with id=24:

I get the following error, when debug=true

AttributeError at /admin/accounts/24/edit/
'NoneType' object has no attribute 'group'

Request Method: POST
Request URL: https://xxxx.de/admin/accounts/24/edit/
Django Version: 1.9.10
Python Executable: /usr/bin/uwsgi-core
Python Version: 2.7.12
Python Path: ['.', '', '/srv/modoboa/env/lib/python2.7', '/srv/modoboa/env/lib/python2.7/plat-x86_64-linux-gnu', '/srv/modoboa/env/lib/python2.7/lib-tk', '/srv/modoboa/env/lib/python2.7/lib-old', '/srv/modoboa/env/lib/python2.7/lib-dynload', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-x86_64-linux-gnu', '/usr/lib/python2.7/lib-tk', '/srv/modoboa/env/local/lib/python2.7/site-packages', '/srv/modoboa/env/lib/python2.7/site-packages']
Server time: Mon, 10 Oct 2016 16:29:47 +0200
Installed Applications:
('django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.sites',
'django.contrib.staticfiles',
'reversion',
'rest_framework.authtoken',
'rest_framework_swagger',
'modoboa',
'modoboa.core',
'modoboa.lib',
'modoboa.admin',
'modoboa.relaydomains',
'modoboa.limits',
'modoboa_amavis',
'modoboa_pdfcredentials',
'modoboa_postfix_autoreply',
'modoboa_sievefilters',
'modoboa_stats')
Installed Middleware:
('x_forwarded_for.middleware.XForwardedForMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'modoboa.lib.middleware.AjaxLoginRedirect',
'modoboa.lib.middleware.CommonExceptionCatcher',
'modoboa.lib.middleware.RequestCatcherMiddleware')

Traceback:

File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response

  1.                 response = self.process_exception_by_middleware(e, request)
    

File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response

  1.                 response = wrapped_callback(request, _callback_args, *_callback_kwargs)
    

File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/utils/decorators.py" in inner

  1.                 return func(_args, *_kwargs)
    

File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/utils/decorators.py" in inner

  1.                 return func(_args, *_kwargs)
    

File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/contrib/auth/decorators.py" in _wrapped_view

  1.             return view_func(request, _args, *_kwargs)
    

File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/contrib/auth/decorators.py" in _wrapped_view

  1.             return view_func(request, _args, *_kwargs)
    

File "/srv/modoboa/env/local/lib/python2.7/site-packages/reversion/revisions.py" in do_revision_context

  1.             return func(_args, *_kwargs)
    

File "/srv/modoboa/env/local/lib/python2.7/site-packages/modoboa/admin/views/identity.py" in editaccount

  1. return AccountForm(request, instances=instances).process()
    

File "/srv/modoboa/env/local/lib/python2.7/site-packages/modoboa/lib/form_utils.py" in process

  1.             self.save()
    

File "/srv/modoboa/env/local/lib/python2.7/site-packages/modoboa/admin/forms/account.py" in save

  1.         "AccountModified", self.instances["general"], self.account
    

File "/srv/modoboa/env/local/lib/python2.7/site-packages/modoboa/lib/events.py" in raiseEvent

  1.     callback(_args, *_kwargs)
    

File "/srv/modoboa/env/local/lib/python2.7/site-packages/modoboa/limits/controls.py" in on_account_modified

  1. if owner.group not in ["SuperAdmins", "Resellers"]:
    

Exception Type: AttributeError at /admin/accounts/24/edit/
Exception Value: 'NoneType' object has no attribute 'group'
Request information:
GET: No GET data

This seems to be looking for an owner of the "User" object, so i should mention, that I deleted the default admin user, with which I created this user. But I can't recall if the User was broken after this, or sometime before.
Since it dies expecting to be "owner" a user(?) I followed the function call to get_object_owner in lib/permissions.py, where the try gets catched and returns None...

After some digging, I executed the following SQL query
UPDATE core_objectaccess SET is_owner=true WHERE id=321;
since then it seems to work.

 id  | object_id | is_owner | content_type_id | user_id 
-----+-----------+----------+-----------------+---------
 321 |        24 | f        |               9 |       4

I searched for object_id=24 and content_type_id=9 because those were the values, which i got from debugging the get_object_owner method.

Not shure what I did though... :-D

Any idea on how this happened and what i did wrong? (and: did I make it worse with the query?)

Thanks!

Originally created by @hennedo on GitHub (Oct 10, 2016). Original GitHub issue: https://github.com/modoboa/modoboa/issues/937 Originally assigned to: @tonioo on GitHub. I have some broken users, as a SuperAdmin i cannot delete those, or change their role from SimpleUser to DomainAdmin (which the user was before I degraded him to SimpleUser..) For example the user with id=24: I get the following error, when debug=true > AttributeError at /admin/accounts/24/edit/ > 'NoneType' object has no attribute 'group' > > Request Method: POST > Request URL: https://xxxx.de/admin/accounts/24/edit/ > Django Version: 1.9.10 > Python Executable: /usr/bin/uwsgi-core > Python Version: 2.7.12 > Python Path: ['.', '', '/srv/modoboa/env/lib/python2.7', '/srv/modoboa/env/lib/python2.7/plat-x86_64-linux-gnu', '/srv/modoboa/env/lib/python2.7/lib-tk', '/srv/modoboa/env/lib/python2.7/lib-old', '/srv/modoboa/env/lib/python2.7/lib-dynload', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-x86_64-linux-gnu', '/usr/lib/python2.7/lib-tk', '/srv/modoboa/env/local/lib/python2.7/site-packages', '/srv/modoboa/env/lib/python2.7/site-packages'] > Server time: Mon, 10 Oct 2016 16:29:47 +0200 > Installed Applications: > ('django.contrib.auth', > 'django.contrib.contenttypes', > 'django.contrib.sessions', > 'django.contrib.messages', > 'django.contrib.sites', > 'django.contrib.staticfiles', > 'reversion', > 'rest_framework.authtoken', > 'rest_framework_swagger', > 'modoboa', > 'modoboa.core', > 'modoboa.lib', > 'modoboa.admin', > 'modoboa.relaydomains', > 'modoboa.limits', > 'modoboa_amavis', > 'modoboa_pdfcredentials', > 'modoboa_postfix_autoreply', > 'modoboa_sievefilters', > 'modoboa_stats') > Installed Middleware: > ('x_forwarded_for.middleware.XForwardedForMiddleware', > 'django.contrib.sessions.middleware.SessionMiddleware', > 'django.middleware.common.CommonMiddleware', > 'django.middleware.csrf.CsrfViewMiddleware', > 'django.contrib.auth.middleware.AuthenticationMiddleware', > 'django.contrib.messages.middleware.MessageMiddleware', > 'django.middleware.locale.LocaleMiddleware', > 'django.middleware.clickjacking.XFrameOptionsMiddleware', > 'modoboa.lib.middleware.AjaxLoginRedirect', > 'modoboa.lib.middleware.CommonExceptionCatcher', > 'modoboa.lib.middleware.RequestCatcherMiddleware') > > Traceback: > > File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response > 1. response = self.process_exception_by_middleware(e, request) > > File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response > 1. response = wrapped_callback(request, _callback_args, *_callback_kwargs) > > File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/utils/decorators.py" in inner > 1. return func(_args, *_kwargs) > > File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/utils/decorators.py" in inner > 1. return func(_args, *_kwargs) > > File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/contrib/auth/decorators.py" in _wrapped_view > 1. return view_func(request, _args, *_kwargs) > > File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/contrib/auth/decorators.py" in _wrapped_view > 1. return view_func(request, _args, *_kwargs) > > File "/srv/modoboa/env/local/lib/python2.7/site-packages/reversion/revisions.py" in do_revision_context > 1. return func(_args, *_kwargs) > > File "/srv/modoboa/env/local/lib/python2.7/site-packages/modoboa/admin/views/identity.py" in editaccount > 1. return AccountForm(request, instances=instances).process() > > File "/srv/modoboa/env/local/lib/python2.7/site-packages/modoboa/lib/form_utils.py" in process > 1. self.save() > > File "/srv/modoboa/env/local/lib/python2.7/site-packages/modoboa/admin/forms/account.py" in save > 1. "AccountModified", self.instances["general"], self.account > > File "/srv/modoboa/env/local/lib/python2.7/site-packages/modoboa/lib/events.py" in raiseEvent > 1. callback(_args, *_kwargs) > > File "/srv/modoboa/env/local/lib/python2.7/site-packages/modoboa/limits/controls.py" in on_account_modified > 1. if owner.group not in ["SuperAdmins", "Resellers"]: > > Exception Type: AttributeError at /admin/accounts/24/edit/ > Exception Value: 'NoneType' object has no attribute 'group' > Request information: > GET: No GET data This seems to be looking for an owner of the "User" object, so i should mention, that I deleted the default admin user, with which I created this user. But I can't recall if the User was broken after this, or sometime before. Since it dies expecting to be "owner" a user(?) I followed the function call to get_object_owner in lib/permissions.py, where the try gets catched and returns None... After some digging, I executed the following SQL query `UPDATE core_objectaccess SET is_owner=true WHERE id=321;` since then it seems to work. ``` id | object_id | is_owner | content_type_id | user_id -----+-----------+----------+-----------------+--------- 321 | 24 | f | 9 | 4 ``` I searched for object_id=24 and content_type_id=9 because those were the values, which i got from debugging the get_object_owner method. Not shure what I did though... :-D Any idea on how this happened and what i did wrong? (and: did I make it worse with the query?) Thanks!
kerem 2026-02-27 11:13:37 +03:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@tonioo commented on GitHub (Oct 10, 2016):

That's indeed a strange issue... How did you remove the default admin ?

<!-- gh-comment-id:252659368 --> @tonioo commented on GitHub (Oct 10, 2016): That's indeed a strange issue... How did you remove the default admin ?
Author
Owner

@hennedo commented on GitHub (Oct 10, 2016):

by giving my own user (with a mailbox) superAdmin rights and then using this user, I clicked on delete. Everything has been done in the Modoboa Webinterface.

<!-- gh-comment-id:252665428 --> @hennedo commented on GitHub (Oct 10, 2016): by giving my own user (with a mailbox) superAdmin rights and then using this user, I clicked on delete. Everything has been done in the Modoboa Webinterface.
Author
Owner

@tonioo commented on GitHub (Oct 10, 2016):

With which version of Modoboa ?

<!-- gh-comment-id:252669006 --> @tonioo commented on GitHub (Oct 10, 2016): With which version of Modoboa ?
Author
Owner

@hennedo commented on GitHub (Oct 10, 2016):

1.6.0

<!-- gh-comment-id:252669427 --> @hennedo commented on GitHub (Oct 10, 2016): 1.6.0
Author
Owner

@tonioo commented on GitHub (Oct 10, 2016):

Ok, I found the issue. Thanks for reporting, I'll fix it soon :-)

<!-- gh-comment-id:252681835 --> @tonioo commented on GitHub (Oct 10, 2016): Ok, I found the issue. Thanks for reporting, I'll fix it soon :-)
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/modoboa-modoboa#803
No description provided.