Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When logout, raising error "AttributeError: 'AnonymousUser' object has no attribute 'profile' #11652

Closed
2 tasks done
jsarola opened this issue May 16, 2024 · 4 comments
Closed
2 tasks done
Assignees
Labels
bug Something is broken.
Milestone

Comments

@jsarola
Copy link

jsarola commented May 16, 2024

Describe the issue

When you are logged in weblate, and you try to logout. This error appears in my sentry:

AttributeError /accounts/logout/
'AnonymousUser' object has no attribute 'profile'

I already tried

  • I've read and searched the documentation.
  • I've searched for similar filed issues in this repository.

Steps to reproduce the behavior

  1. Go To top menu, user option
  2. Select Sign Out

Expected behavior

I want to see logout user, and going to home page, or a link to home page.

Screenshots

No response

Exception traceback

No response

How do you run Weblate?

PyPI module

Weblate versions

  • Weblate: 5.5.5
  • Django: 5.0.4
  • siphashc: 2.1
  • translate-toolkit: 3.13.0
  • lxml: 5.2.1
  • pillow: 10.3.0
  • nh3: 0.2.14
  • python-dateutil: 2.8.2
  • social-auth-core: 4.5.4
  • social-auth-app-django: 5.4.1
  • django-crispy-forms: 2.1
  • oauthlib: 3.2.2
  • django-compressor: 4.4
  • djangorestframework: 3.15.1
  • django-filter: 24.2
  • django-appconf: 1.0.5
  • user-agents: 2.2.0
  • filelock: 3.13.1
  • rapidfuzz: 2.13.7
  • openpyxl: 3.1.2
  • celery: 5.4.0
  • django-celery-beat: 2.6.0
  • kombu: 5.3.7
  • translation-finder: 2.16
  • weblate-language-data: 2024.4
  • html2text: 2024.2.26
  • pycairo: 1.23.0
  • PyGObject: 3.42.2
  • diff-match-patch: 20230430
  • requests: 2.31.0
  • django-redis: 5.4.0
  • hiredis: 2.3.2
  • sentry-sdk: 1.45.0
  • Cython: 3.0.10
  • misaka: 2.1.1
  • GitPython: 3.1.31
  • borgbackup: 1.2.6
  • pyparsing: 3.1.1
  • ahocorasick_rs: 0.22.0
  • python-redis-lock: 4.0.0
  • charset-normalizer: 2.0.12
  • Python: 3.10.12
  • Git: 2.34.1
  • psycopg: 3.1.12
  • psycopg-binary: 3.1.12
  • phply: 1.2.6
  • ruamel.yaml: 0.17.21
  • tesserocr: 2.6.2
  • boto3: 1.28.85
  • zeep: 4.1.0
  • aeidon: 1.14.1
  • iniparse: 0.5
  • Mercurial: 6.4
  • git-svn: 2.34.1
  • git-review: 2.3.1
  • PostgreSQL server: 14.11
  • Database backends: django.db.backends.postgresql
  • PostgreSQL implementation: psycopg3 (binary)
  • Cache backends: default:RedisCache, avatar:FileBasedCache
  • Email setup: anymail.backends.sendgrid.EmailBackend: localhost
  • OS encoding: filesystem=utf-8, default=utf-8
  • Celery: redis:https://localhost:6379, redis:https://localhost:6379, regular
  • Platform: Linux 5.15.0-105-generic (x86_64)

Weblate deploy checks

System check identified no issues (1 silenced).

Additional context

I check the file ~/.virtualenvs/weblate/lib/python3.10/site-packages/weblate/trans/context_processors.py and edit the tab in line 128, and now I haven't the error, but the logout sends to admin page login, not the home page.

@nijel
Copy link
Member

nijel commented May 17, 2024

This should not happen. While Django logout indeed sets AnonymousUser as a request user upon logout, the logout request should just redirect and not render anything. And the next request will get a proper User instance.

Did you do any code customization in Weblate? Does the configuration follow what is specified in settings_example.py?

@nijel nijel added the question This is more a question for the support than an issue. label May 17, 2024
Copy link

This issue has been marked as a question by a Weblate team member. Why? Because it belongs more to the professional Weblate Care or community Discussions than here. We strive to answer these reasonably fast here, too, but purchasing the support subscription is more responsible and faster for your business. And it makes Weblate stronger as well. Thanks!

In case your question is already answered, making a donation is the right way to say thank you!

@jsarola
Copy link
Author

jsarola commented May 20, 2024

I'm very sorry for the noise. I just went through the entire settings_example.py file line by line, and I found that the LOGOUT_REDIRECT_URL option was not available in my version. I have added it and undone the changes and everything works correctly.
In some upgrade I miss creating this new variable, and only now, when checking last version, I see the error.

Thank you.

@nijel nijel added bug Something is broken. and removed question This is more a question for the support than an issue. labels May 21, 2024
@nijel nijel self-assigned this May 21, 2024
@nijel nijel added this to the 5.6 milestone May 21, 2024
@nijel nijel closed this as completed in 432439e May 21, 2024
Copy link

Thank you for your report; the issue you have reported has just been fixed.

  • In case you see a problem with the fix, please comment on this issue.
  • In case you see a similar problem, please open a separate issue.
  • If you are happy with the outcome, don’t hesitate to support Weblate by making a donation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is broken.
Projects
None yet
Development

No branches or pull requests

2 participants