From 6aa9170982dfb6bd8dac0eab06f89a8741f2fb5e Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Fri, 4 Mar 2016 10:02:32 +0100 Subject: [PATCH] Fix removal of admin right when users have admin attributes but is already admin (fixes #10195) --- mellon/adapters.py | 2 +- tests/test_default_adapter.py | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/mellon/adapters.py b/mellon/adapters.py index e871ed6..99224a1 100644 --- a/mellon/adapters.py +++ b/mellon/adapters.py @@ -182,7 +182,7 @@ class DefaultAdapter(object): user.is_superuser = True attribute_set = True self.logger.info('flag is_staff and is_superuser added to user %s', user) - break + break else: if user.is_superuser or user.is_staff: user.is_staff = False diff --git a/tests/test_default_adapter.py b/tests/test_default_adapter.py index 7b781a8..7d497c4 100644 --- a/tests/test_default_adapter.py +++ b/tests/test_default_adapter.py @@ -121,7 +121,12 @@ def test_provision_is_superuser(settings, django_user_model, caplog): } user = SAMLBackend().authenticate(saml_attributes=saml_attributes) assert user.is_superuser is True + assert user.is_staff is True assert 'flag is_staff and is_superuser added' in caplog.text() + user = SAMLBackend().authenticate(saml_attributes=saml_attributes) + assert user.is_superuser is True + assert user.is_staff is True + assert not 'flag is_staff and is_superuser removed' in caplog.text() def test_provision_absent_attribute(settings, django_user_model, caplog):