westerveltco / django-simple-nav

A simple, flexible, and extensible navigation menu for Django
https://django-simple-nav.westervelt.dev
MIT License
10 stars 0 forks source link

move `request.user` check to earlier in `check_item_permissions` #76

Closed joshuadavidthomas closed 2 months ago

joshuadavidthomas commented 2 months ago

The cast needed to make static type checkers happy fails if django.contrib.auth is installed but there is no user attached to a request.

This can happen for a couple of reasons:

Moving the check to before the cast allows the function to early if there is no user attached. We also make the assumption that if the item has any permissions defined and there is no request user, that the item should be hidden.