From b1b79d1245153086aec4b00e056a2ee3293de05b Mon Sep 17 00:00:00 2001 From: Aaron Kable Date: Fri, 26 Mar 2021 18:20:39 +0800 Subject: [PATCH] Refresh user profile on state change to force permision changes. --- allianceauth/authentication/models.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/allianceauth/authentication/models.py b/allianceauth/authentication/models.py index c71721ef..0de48191 100755 --- a/allianceauth/authentication/models.py +++ b/allianceauth/authentication/models.py @@ -81,6 +81,11 @@ class UserProfile(models.Model): 'info' ) from allianceauth.authentication.signals import state_changed + + # We need to ensure we get up to date perms here as they will have just changed. + # Clear all attribute caches and reload the model that will get passed to the signals! + self.refresh_from_db() + state_changed.send( sender=self.__class__, user=self.user, state=self.state )