Fix removal of admin right when users have admin attributes but is already admin (fixes #10195)

This commit is contained in:
Benjamin Dauvergne 2016-03-04 10:02:32 +01:00
parent bac013c19f
commit 6aa9170982
2 changed files with 6 additions and 1 deletions

View File

@ -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

View File

@ -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):