mediacms-io / mediacms

MediaCMS is a modern, fully featured open source video and media CMS, written in Python/Django and React, featuring a REST API.
https://mediacms.io
GNU Affero General Public License v3.0
2.88k stars 534 forks source link

When GLOBAL_LOGIN_REQUIRED = True 500 error is shown #1081

Open davidchua opened 1 month ago

davidchua commented 1 month ago

Describe the issue When installing mediacms (Single Server), setting "GLOBAL_LOGIN_REQUIRED = True" returns an error

AttributeError: 'WSGIRequest' object has no attribute 'user'
Internal Server Error: /favicon.ico
Traceback (most recent call last):
  File "/home/mediacms.io/lib/python3.10/site-packages/django/core/handlers/exception.py", line 55, in inner
    response = get_response(request)
  File "/home/mediacms.io/lib/python3.10/site-packages/django/utils/deprecation.py", line 133, in __call__
    response = self.process_request(request)
  File "/home/mediacms.io/lib/python3.10/site-packages/login_required/middleware.py", line 55, in process_request
    return self._login_required(request)
  File "/home/mediacms.io/lib/python3.10/site-packages/login_required/middleware.py", line 22, in _login_required
    if request.user.is_authenticated:
AttributeError: 'WSGIRequest' object has no attribute 'user'

To Reproduce Steps to reproduce the issue:

  1. Follow the instructions in https://github.com/mediacms-io/mediacms/blob/main/docs/admins_docs.md#2-server-installation
  2. Access the web interface and see that the instance UI loads without issue. Ensure you're not signed in.
  3. in mediacms/cms/local_settings.py set GLOBAL_LOGIN_REQUIRED = True
  4. Restart services sudo systemctl restart mediacms celery_short celery_long
  5. Access the webpage again and you should see a 500 error with the logs returned above.

Expected behavior

Webpage should load with a Login Screen when you're not logged in.

Environment (please complete the following information):

Additional context

Commit hash of directory is

commit 6bbd4c28094cbd64af2ed2dc120884510fc75093 (HEAD -> main, origin/main, origin/HEAD)
davidchua commented 1 month ago

I've found the issue and opened PR #1082 that should fix it.