Merge branch 'purge_state_cache' into 'v2.9.x'

Refresh user profile on state change to force permission changes.

See merge request allianceauth/allianceauth!1296
This commit is contained in:
Ariel Rin 2021-07-03 04:25:34 +00:00
commit eafc6074c1

View File

@ -77,6 +77,11 @@ class UserProfile(models.Model):
'info' 'info'
) )
from allianceauth.authentication.signals import state_changed 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( state_changed.send(
sender=self.__class__, user=self.user, state=self.state sender=self.__class__, user=self.user, state=self.state
) )