unfoldadmin / django-unfold

Modern Django admin theme for seamless interface development
https://unfoldadmin.com
MIT License
1.04k stars 96 forks source link

Problem with Unfold sidebar permissions #350

Closed jverdasca closed 1 week ago

jverdasca commented 1 month ago

When logging in with a user with fewer permissions, the sidebar items disappear and when logging in with a user with more permissions, these items are not reset, that is, the items shown in the sidebar to the user with more permissions remain the same as those shown to the user with fewer permissions.

The problem is that the way unfold handles permissions changes the settings dictionary defined in the Django settings in the UNFOLD variable.

The problem occurs here and the Django settings are changed here, thus changing the UNFOLD settings variable due to the reference in navigation variable. A solution to this problem is to use deepcopy from Python's copy module (documentation here), which ensures that settings.UNFOLD remains in its original state and navigation variable contains a copy of UNFOLD setting.

Using deepcopy as I demonstrate below solves the problem described

imagem

Edit: I am using the SIDEBAR settings the same way as described in here

summerthe commented 1 month ago

@jverdasca you are probably using old unfold version. This issue has been fixed in some of the recent release

lukasvinclav commented 1 week ago

Yes, this one is supposed to be fixed. I'm closing this issue.